# sure if this can be avoided.
[-Subroutines::ProhibitNestedSubs]
-# Make an exception for very short (possibly time-critical) subs.
+# Make an exception for very short time-critical subs.
[Subroutines::RequireArgUnpacking]
short_subroutine_statements = 2
# Disagree: The advantages of 'use constant' greatly outweigh the few
-# disadvantages. Perl::Tidy relies heavily on constants for efficient and
-# robust coding of array indexes and for compiling out debug code, and to avoid
-# autovivication problems that would occur if hashes were used instead.
+# disadvantages. Perl::Tidy relies heavily on constants
+# -for efficient and robust coding of array indexes,
+# -for avoiding autovivication issues if hashes were used instead,
+# -and for eliminating debug code during compilation.
[-ValuesAndExpressions::ProhibitConstantPragma]
# Disagree: adding quotes on here doc terminators causes needless "line noise"
} ## end sub get_convergence_check
sub get_output_line_number {
- return $_[0]->[_output_line_number_];
+ my $self = shift;
+ return $self->[_output_line_number_];
}
sub decrement_output_line_number {
- $_[0]->[_output_line_number_]--;
+ my $self = shift;
+ $self->[_output_line_number_]--;
return;
}
sub get_consecutive_nonblank_lines {
- return $_[0]->[_consecutive_nonblank_lines_];
+ my $self = shift;
+ return $self->[_consecutive_nonblank_lines_];
}
sub get_consecutive_blank_lines {
- return $_[0]->[_consecutive_blank_lines_];
+ my $self = shift;
+ return $self->[_consecutive_blank_lines_];
}
sub reset_consecutive_blank_lines {
- $_[0]->[_consecutive_blank_lines_] = 0;
+ my $self = shift;
+ $self->[_consecutive_blank_lines_] = 0;
return;
}
package Perl::Tidy::IndentationItem;
use strict;
use warnings;
+
our $VERSION = '20230912.04';
BEGIN {
return $deleted_spaces;
} ## end sub tentatively_decrease_available_spaces
+# time-critical sub
sub get_spaces {
return $_[0]->[_spaces_];
}
sub get_standard_spaces {
- return $_[0]->[_standard_spaces_];
+ my $self = shift;
+ return $self->[_standard_spaces_];
}
+# time-critical sub
sub get_marked {
return $_[0]->[_marked_];
}
} ## end sub set_marked
sub get_available_spaces {
- return $_[0]->[_available_spaces_];
+ my $self = shift;
+ return $self->[_available_spaces_];
}
sub decrease_SPACES {
} ## end sub decrease_available_spaces
sub get_align_seqno {
- return $_[0]->[_align_seqno_];
+ my $self = shift;
+ return $self->[_align_seqno_];
}
sub get_recoverable_spaces {
- return $_[0]->[_recoverable_spaces_];
+ my $self = shift;
+ return $self->[_recoverable_spaces_];
}
sub set_recoverable_spaces {
} ## end sub increase_recoverable_spaces
sub get_ci_level {
- return $_[0]->[_ci_level_];
+ my $self = shift;
+ return $self->[_ci_level_];
}
sub get_level {
- return $_[0]->[_level_];
+ my $self = shift;
+ return $self->[_level_];
}
sub get_spaces_level_ci {
}
sub get_lp_item_index {
- return $_[0]->[_lp_item_index_];
+ my $self = shift;
+ return $self->[_lp_item_index_];
}
sub get_K_begin_line {
- return $_[0]->[_K_begin_line_];
+ my $self = shift;
+ return $self->[_K_begin_line_];
}
sub get_K_extra_space {
- return $_[0]->[_K_extra_space_];
+ my $self = shift;
+ return $self->[_K_extra_space_];
}
sub set_have_child {
} ## end sub set_have_child
sub get_have_child {
- return $_[0]->[_have_child_];
+ my $self = shift;
+ return $self->[_have_child_];
}
sub set_arrow_count {
} ## end sub set_arrow_count
sub get_arrow_count {
- return $_[0]->[_arrow_count_];
+ my $self = shift;
+ return $self->[_arrow_count_];
}
sub set_comma_count {
} ## end sub set_comma_count
sub get_comma_count {
- return $_[0]->[_comma_count_];
+ my $self = shift;
+ return $self->[_comma_count_];
}
sub set_closed {
} ## end sub set_closed
sub get_closed {
- return $_[0]->[_closed_];
+ my $self = shift;
+ return $self->[_closed_];
}
1;
use strict;
use warnings;
use Carp;
-use English qw( -no_match_vars );
+
+{ #<<< A non-indenting brace to contain all lexical variables
+
our $VERSION = '20230912.04';
+use English qw( -no_match_vars );
use Perl::Tidy::VerticalAligner::Alignment;
use Perl::Tidy::VerticalAligner::Line;
use constant EMPTY_STRING => q{};
use constant SPACE => q{ };
-{ #<<< A non-indenting brace to contain all lexical variables
-
# The Perl::Tidy::VerticalAligner package collects output lines and
# attempts to line up certain common tokens, such as => and #, which are
# identified by the calling routine.
use constant DEBUG_TABS => 0;
my $debug_warning = sub {
- print {*STDOUT} "VALIGN_DEBUGGING with key $_[0]\n";
+ my $msg = shift;
+ print {*STDOUT} "VALIGN_DEBUGGING with key $msg\n";
return;
};
} ## end sub initialize_for_new_group
sub group_line_count {
- return +@{ $_[0]->[_rgroup_lines_] };
+ my $self = shift;
+ return +@{ $self->[_rgroup_lines_] };
}
# interface to Perl::Tidy::Diagnostics routines
sub get_output_line_number {
+ # Return the output line number to external modules.
# The output line number reported to a caller =
# the number of items still in the buffer +
# the number of items written.
- return $_[0]->group_line_count() +
- $_[0]->[_file_writer_object_]->get_output_line_number();
+ my $self = shift;
+ return $self->group_line_count() +
+ $self->[_file_writer_object_]->get_output_line_number();
} ## end sub get_output_line_number
###############################
# on a single column being aligned
#
#####################################################################
+
package Perl::Tidy::VerticalAligner::Alignment;
use strict;
use warnings;
-{ #<<< A non-indenting brace
-
our $VERSION = '20230912.04';
sub new {
}
sub get_column {
- return $_[0]->{'column'};
+ my $self = shift;
+ return $self->{'column'};
}
sub increment_column {
- $_[0]->{'column'} += $_[1];
-
+ my ( $self, $pad ) = @_;
+ $self->{'column'} += $pad;
return;
}
sub save_column {
- $_[0]->{'saved_column'} = $_[0]->{'column'};
+ my $self = shift;
+ $self->{'saved_column'} = $self->{'column'};
return;
}
sub restore_column {
- $_[0]->{'column'} = $_[0]->{'saved_column'};
+ my $self = shift;
+ $self->{'column'} = $self->{'saved_column'};
return;
}
-} ## end of package VerticalAligner::Alignment
1;
package Perl::Tidy::VerticalAligner::Line;
use strict;
use warnings;
-use English qw( -no_match_vars );
+
our $VERSION = '20230912.04';
+use English qw( -no_match_vars );
sub AUTOLOAD {
exit 1;
} ## end sub AUTOLOAD
-{
+# Constructor may be called as a class method
+sub new {
+ my ( $class, $ri ) = @_;
+ my $self = bless $ri, $class;
+ return $self;
+}
- # Constructor may be called as a class method
- sub new {
- my ( $class, $ri ) = @_;
- my $self = bless $ri, $class;
- return $self;
- }
+sub get_column {
+ my ( $self, $j ) = @_;
+ my $alignment = $self->{ralignments}->[$j];
+ return unless defined($alignment);
+ return $alignment->get_column();
+} ## end sub get_column
- sub get_column {
- my ( $self, $j ) = @_;
- my $alignment = $self->{ralignments}->[$j];
- return unless defined($alignment);
- return $alignment->get_column();
- } ## end sub get_column
+sub current_field_width {
+ my ( $self, $j ) = @_;
- sub current_field_width {
- my ( $self, $j ) = @_;
- my $col_j = 0;
- my $col_jm = 0;
+ # Return number of columns of space between alignments $j and $j-1
- my $alignment_j = $self->{ralignments}->[$j];
- $col_j = $alignment_j->get_column() if defined($alignment_j);
+ my $alignment_j = $self->{ralignments}->[$j];
+ my $col_j = defined($alignment_j) ? $alignment_j->get_column() : 0;
+ return $col_j if ( $j == 0 );
- if ( $j > 0 ) {
- my $alignment_jm = $self->{ralignments}->[ $j - 1 ];
- $col_jm = $alignment_jm->get_column() if defined($alignment_jm);
- }
- return $col_j - $col_jm;
- } ## end sub current_field_width
+ my $alignment_jm = $self->{ralignments}->[ $j - 1 ];
+ my $col_jm = defined($alignment_jm) ? $alignment_jm->get_column() : 0;
+ return $col_j - $col_jm;
- sub increase_field_width {
+} ## end sub current_field_width
- my ( $self, $j, $pad ) = @_;
- my $jmax = $self->{jmax};
- foreach ( $j .. $jmax ) {
- my $alignment = $self->{ralignments}->[$_];
- if ( defined($alignment) ) {
- $alignment->increment_column($pad);
- }
- }
- return;
- } ## end sub increase_field_width
+sub increase_field_width {
- sub get_available_space_on_right {
- my $jmax = $_[0]->{jmax};
- return $_[0]->{maximum_line_length} - $_[0]->get_column($jmax);
+ my ( $self, $j, $pad ) = @_;
+ my $jmax = $self->{jmax};
+ foreach ( $j .. $jmax ) {
+ my $alignment = $self->{ralignments}->[$_];
+ if ( defined($alignment) ) {
+ $alignment->increment_column($pad);
+ }
}
-}
+ return;
+} ## end sub increase_field_width
+sub get_available_space_on_right {
+ my $self = shift;
+ my $jmax = $self->{jmax};
+ return $self->{maximum_line_length} - $self->get_column($jmax);
+}
1;