| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Tidy::VerticalAligner::Line; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
##################################################################### |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# The Perl::Tidy::VerticalAligner::Line class supplies an object to |
|
6
|
|
|
|
|
|
|
# contain a single output line. It allows manipulation of the |
|
7
|
|
|
|
|
|
|
# alignment columns on that line. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
##################################################################### |
|
10
|
|
|
|
|
|
|
|
|
11
|
44
|
|
|
44
|
|
252
|
use strict; |
|
|
44
|
|
|
|
|
68
|
|
|
|
44
|
|
|
|
|
1274
|
|
|
12
|
44
|
|
|
44
|
|
339
|
use warnings; |
|
|
44
|
|
|
|
|
68
|
|
|
|
44
|
|
|
|
|
2377
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '20260705'; |
|
15
|
44
|
|
|
44
|
|
180
|
use English qw( -no_match_vars ); |
|
|
44
|
|
|
|
|
63
|
|
|
|
44
|
|
|
|
|
207
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
|
18
|
|
|
|
|
|
|
# List of hash keys to prevent -duk from listing them. |
|
19
|
|
|
|
|
|
|
my @unique_hash_keys_uu = qw( maximum_line_length ); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Catch any undefined sub calls so that we are sure to get |
|
25
|
|
|
|
|
|
|
# some diagnostic information. This sub should never be called |
|
26
|
|
|
|
|
|
|
# except for a programming error. |
|
27
|
0
|
|
|
0
|
|
0
|
our $AUTOLOAD; |
|
28
|
0
|
0
|
|
|
|
0
|
return if ( $AUTOLOAD =~ /\bDESTROY$/ ); |
|
29
|
0
|
|
|
|
|
0
|
my ( $pkg, $fname, $lno ) = caller(); |
|
30
|
0
|
|
|
|
|
0
|
my $my_package = __PACKAGE__; |
|
31
|
0
|
|
|
|
|
0
|
print {*STDERR} <<EOM; |
|
|
0
|
|
|
|
|
0
|
|
|
32
|
|
|
|
|
|
|
====================================================================== |
|
33
|
|
|
|
|
|
|
Error detected in package '$my_package', version $VERSION |
|
34
|
|
|
|
|
|
|
Received unexpected AUTOLOAD call for sub '$AUTOLOAD' |
|
35
|
|
|
|
|
|
|
Called from package: '$pkg' |
|
36
|
|
|
|
|
|
|
Called from File '$fname' at line '$lno' |
|
37
|
|
|
|
|
|
|
This error is probably due to a recent programming change |
|
38
|
|
|
|
|
|
|
====================================================================== |
|
39
|
|
|
|
|
|
|
EOM |
|
40
|
0
|
|
|
|
|
0
|
exit 1; |
|
41
|
|
|
|
|
|
|
} ## end sub AUTOLOAD |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
0
|
|
|
sub DESTROY { |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# required to avoid call to AUTOLOAD in some versions of perl |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Constructor may be called as a class method |
|
49
|
|
|
|
|
|
|
sub new { |
|
50
|
|
|
|
|
|
|
|
|
51
|
3637
|
|
|
3637
|
0
|
6935
|
my ( $class, $rhash ) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Create a new VerticalAligner::Line object |
|
54
|
|
|
|
|
|
|
# Given: |
|
55
|
|
|
|
|
|
|
# $rhash = ref to hash for a Line |
|
56
|
|
|
|
|
|
|
# This hash contains parameters describing one line. |
|
57
|
|
|
|
|
|
|
# The parameters currently used by this object are: |
|
58
|
|
|
|
|
|
|
# {ralignments} = ref to array of vertical alignment columns |
|
59
|
|
|
|
|
|
|
# {jmax} = max index of {ralignments} |
|
60
|
|
|
|
|
|
|
# {maximum_line_length} = maximum number of spaces for this line |
|
61
|
|
|
|
|
|
|
|
|
62
|
3637
|
|
|
|
|
6228
|
my $self = bless $rhash, $class; |
|
63
|
3637
|
|
|
|
|
7141
|
return $self; |
|
64
|
|
|
|
|
|
|
} ## end sub new |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_column { |
|
67
|
|
|
|
|
|
|
|
|
68
|
3035
|
|
|
3035
|
0
|
4053
|
my ( $self, $j ) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Return the current column number of alignment $j |
|
71
|
|
|
|
|
|
|
|
|
72
|
3035
|
|
|
|
|
3909
|
my $alignment = $self->{ralignments}->[$j]; |
|
73
|
3035
|
50
|
|
|
|
4510
|
return unless ( defined($alignment) ); |
|
74
|
3035
|
|
|
|
|
5628
|
return $alignment->get_column(); |
|
75
|
|
|
|
|
|
|
} ## end sub get_column |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub current_field_width { |
|
78
|
|
|
|
|
|
|
|
|
79
|
4043
|
|
|
4043
|
0
|
5074
|
my ( $self, $j ) = @_; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Return number of columns of space between alignments $j and $j-1 |
|
82
|
|
|
|
|
|
|
|
|
83
|
4043
|
|
|
|
|
4763
|
my $alignment_j = $self->{ralignments}->[$j]; |
|
84
|
4043
|
50
|
|
|
|
6699
|
my $col_j = defined($alignment_j) ? $alignment_j->get_column() : 0; |
|
85
|
4043
|
100
|
|
|
|
6441
|
return $col_j if ( $j == 0 ); |
|
86
|
|
|
|
|
|
|
|
|
87
|
2894
|
|
|
|
|
3621
|
my $alignment_jm = $self->{ralignments}->[ $j - 1 ]; |
|
88
|
2894
|
50
|
|
|
|
4841
|
my $col_jm = defined($alignment_jm) ? $alignment_jm->get_column() : 0; |
|
89
|
2894
|
|
|
|
|
4239
|
return $col_j - $col_jm; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} ## end sub current_field_width |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub increase_field_width { |
|
94
|
|
|
|
|
|
|
|
|
95
|
3060
|
|
|
3060
|
0
|
4129
|
my ( $self, $j, $pad ) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# Increase the width of alignment field $j by $pad spaces. |
|
98
|
|
|
|
|
|
|
# So we must increase the widths of the higher alignments by $pad spaces. |
|
99
|
3060
|
|
|
|
|
3685
|
my $jmax = $self->{jmax}; |
|
100
|
3060
|
|
|
|
|
4474
|
foreach ( $j .. $jmax ) { |
|
101
|
7228
|
|
|
|
|
8015
|
my $alignment = $self->{ralignments}->[$_]; |
|
102
|
7228
|
50
|
|
|
|
9289
|
if ( defined($alignment) ) { |
|
103
|
7228
|
|
|
|
|
10332
|
$alignment->increment_column($pad); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
3060
|
|
|
|
|
4071
|
return; |
|
107
|
|
|
|
|
|
|
} ## end sub increase_field_width |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub get_available_space_on_right { |
|
110
|
1811
|
|
|
1811
|
0
|
2449
|
my $self = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# Return the number of unused columns to the right of the last alignment |
|
113
|
1811
|
|
|
|
|
2632
|
my $jmax = $self->{jmax}; |
|
114
|
1811
|
|
|
|
|
4097
|
return $self->{maximum_line_length} - $self->get_column($jmax); |
|
115
|
|
|
|
|
|
|
} ## end sub get_available_space_on_right |
|
116
|
|
|
|
|
|
|
1; |