_K_arrival_order_matches_ => $i++,
_K_sequence_error_msg_ => $i++,
_K_last_arrival_ => $i++,
+ _save_logfile_ => $i++,
};
}
my ( $package0, $filename0, $line0, $subroutine0 ) = caller(0);
my ( $package1, $filename1, $line1, $subroutine1 ) = caller(1);
my ( $package2, $filename2, $line2, $subroutine2 ) = caller(2);
+ my $pkg = __PACKAGE__;
Die(<<EOM);
==============================================================================
which was called from line $line1 of sub '$subroutine2'
Message: '$msg'
This is probably an error introduced by a recent programming change.
-Perl::Tidy::FileWriter.pm reports VERSION='$VERSION'.
+$pkg reports VERSION='$VERSION'.
==============================================================================
EOM
$self->[_K_arrival_order_matches_] = 0;
$self->[_K_sequence_error_msg_] = EMPTY_STRING;
$self->[_K_last_arrival_] = -1;
+ $self->[_save_logfile_] = defined($logger_object);
# save input stream name for local error messages
$input_stream_name = EMPTY_STRING;
return;
}
+# This sub call allows termination of logfile writing for efficiency when we
+# know that the logfile will not be saved.
+sub set_save_logfile {
+ my ( $self, $save_logfile ) = @_;
+ $self->[_save_logfile_] = $save_logfile;
+ return;
+}
+
sub want_blank_line {
my $self = shift;
unless ( $self->[_consecutive_blank_lines_] ) {
}
sub write_blank_code_line {
- my $self = shift;
- my $forced = shift;
- my $rOpts = $self->[_rOpts_];
+ my ( $self, $forced ) = @_;
+
+ # Write a blank line of code, given:
+ # $forced = optional flag which, if set, forces the blank line
+ # to be written. This allows the -mbl flag to be temporarily
+ # exceeded.
+
+ my $rOpts = $self->[_rOpts_];
return
if (!$forced
&& $self->[_consecutive_blank_lines_] >=
return;
}
- $self->write_line("\n");
+ $self->[_line_sink_object_]->write_line("\n");
+ $self->[_output_line_number_]++;
+
$self->[_consecutive_blank_lines_]++;
$self->[_consecutive_new_blank_lines_]++ if ($forced);
sub write_code_line {
my ( $self, $str, $K ) = @_;
+ # Write a line of code, given
+ # $str = the line of code
+ # $K = an optional check integer which, if if given, must
+ # increase monotonically. This was added to catch cache
+ # sequence errors in the vertical aligner.
+
$self->[_consecutive_blank_lines_] = 0;
$self->[_consecutive_new_blank_lines_] = 0;
$self->[_consecutive_nonblank_lines_]++;
- $self->write_line($str);
+
+ $self->[_line_sink_object_]->write_line($str);
+ if ( chomp $str ) { $self->[_output_line_number_]++; }
+ if ( $self->[_save_logfile_] ) { $self->check_line_lengths($str) }
#----------------------------
# Convergence and error check
sub write_line {
my ( $self, $str ) = @_;
+ # Write a line directly to the output, without any counting of blank or
+ # non-blank lines.
+
$self->[_line_sink_object_]->write_line($str);
+ if ( chomp $str ) { $self->[_output_line_number_]++; }
+ if ( $self->[_save_logfile_] ) { $self->check_line_lengths($str) }
- if ( chomp $str ) { $self->[_output_line_number_]++; }
+ return;
+}
+
+sub check_line_lengths {
+ my ( $self, $str ) = @_;
+
+ # collect info on line lengths for logfile
# This calculation of excess line length ignores any internal tabs
my $rOpts = $self->[_rOpts_];
}
sub report_line_length_errors {
- my $self = shift;
+ my $self = shift;
+
+ # Write summary info about line lengths to the log file
+
my $rOpts = $self->[_rOpts_];
my $line_length_error_count = $self->[_line_length_error_count_];
if ( $line_length_error_count == 0 ) {