# scanned at once for some particular condition of interest. It was
# particularly useful for developing guessing strategies.
#
-# NOTE: This feature is deactivated in final releases but can be
-# reactivated for debugging by un-commenting the 'I' options flag
-#
#####################################################################
package Perl::Tidy::Diagnostics;
}
sub write_diagnostics {
- my ( $self, $msg ) = @_;
+ my ( $self, $msg, $line_number ) = @_;
+
+ # Write a message to the diagnostics file
+ # Input parameters:
+ # $msg = string describing the event
+ # $line_number = optional line number
unless ( $self->{_write_diagnostics_count} ) {
open( $self->{_fh}, ">", "DIAGNOSTICS" )
or Perl::Tidy::Die("couldn't open DIAGNOSTICS: $ERRNO\n");
}
+ if ( defined($line_number) ) {
+ $msg = "$line_number:\t$msg";
+ }
+
my $fh = $self->{_fh};
my $last_diagnostic_file = $self->{_last_diagnostic_file};
my $input_file = $self->{_input_file};
$fh->print("\nFILE:$input_file\n");
}
$self->{_last_diagnostic_file} = $input_file;
- my $input_line_number = Perl::Tidy::Tokenizer::get_input_line_number();
- $fh->print("$input_line_number:\t$msg");
+ $fh->print($msg);
$self->{_write_diagnostics_count}++;
return;
}
1;
-
return;
}
+ # Available for debugging but not currently used:
sub write_diagnostics {
- my ($msg) = @_;
+ my ( $msg, $line_number ) = @_;
if ($diagnostics_object) {
- $diagnostics_object->write_diagnostics($msg);
+ $diagnostics_object->write_diagnostics( $msg, $line_number );
}
return;
} ## end sub write_diagnostics
return $self->[_unexpected_error_count_];
}
-# interface to Perl::Tidy::Diagnostics routines
+# Interface to Perl::Tidy::Diagnostics
sub write_diagnostics {
- my $msg = shift;
- if ( $tokenizer_self->[_diagnostics_object_] ) {
- $tokenizer_self->[_diagnostics_object_]->write_diagnostics($msg);
+ my ($msg) = @_;
+ my $input_line_number = $tokenizer_self->[_last_line_number_];
+ my $diagnostics_object = $tokenizer_self->[_diagnostics_object_];
+ if ($diagnostics_object) {
+ $diagnostics_object->write_diagnostics( $msg, $input_line_number );
}
return;
} ## end sub write_diagnostics