line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::T5::Message; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
344
|
use 5.010001; |
|
25
|
|
|
|
|
96
|
|
4
|
25
|
|
|
25
|
|
109
|
use warnings; |
|
25
|
|
|
|
|
37
|
|
|
25
|
|
|
|
|
478
|
|
5
|
25
|
|
|
25
|
|
107
|
use strict; |
|
25
|
|
|
|
|
40
|
|
|
25
|
|
|
|
|
8748
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
HTML::T5::Message - Message object for the Tidy functionality |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 EXPORTS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
None. It's all object-based. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 METHODS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Almost everything is an accessor. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 new( $file, $line, $column, $text ) |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Create an object. It's not very exciting. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
C<$file> can be C or an empty string, in which case it will not appear in messages. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
179
|
|
|
179
|
1
|
6276
|
my $class = shift; |
29
|
|
|
|
|
|
|
|
30
|
179
|
|
|
|
|
195
|
my $file = shift; |
31
|
179
|
|
|
|
|
186
|
my $type = shift; |
32
|
179
|
|
100
|
|
|
336
|
my $line = shift || 0; |
33
|
179
|
|
100
|
|
|
295
|
my $column = shift || 0; |
34
|
179
|
|
|
|
|
188
|
my $text = shift; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Add an element that says what tag caused the error (B, TR, etc) |
37
|
|
|
|
|
|
|
# so that we can match 'em up down the road. |
38
|
179
|
|
|
|
|
516
|
my $self = { |
39
|
|
|
|
|
|
|
_file => $file, |
40
|
|
|
|
|
|
|
_type => $type, |
41
|
|
|
|
|
|
|
_line => $line, |
42
|
|
|
|
|
|
|
_column => $column, |
43
|
|
|
|
|
|
|
_text => $text, |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
179
|
|
|
|
|
283
|
bless $self, $class; |
47
|
|
|
|
|
|
|
|
48
|
179
|
|
|
|
|
332
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 as_string() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns a nicely-formatted string for printing out to stdout or some similar user thing. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub as_string { |
58
|
61
|
|
|
61
|
1
|
16371
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
61
|
|
|
|
|
157
|
my %strings = ( |
61
|
|
|
|
|
|
|
1 => 'Info', |
62
|
|
|
|
|
|
|
2 => 'Warning', |
63
|
|
|
|
|
|
|
3 => 'Error', |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
61
|
|
|
|
|
104
|
my $msg = $strings{$self->type} . ': ' . $self->text; |
67
|
|
|
|
|
|
|
|
68
|
61
|
100
|
66
|
|
|
109
|
if ( $self->line && $self->column ) { |
69
|
59
|
|
|
|
|
91
|
$msg = sprintf( '(%d:%d) %s', $self->line, $self->column, $msg ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
61
|
|
100
|
|
|
125
|
my $file = $self->file // ''; |
73
|
61
|
100
|
|
|
|
116
|
if ( $file ne '' ) { |
74
|
24
|
|
|
|
|
46
|
$msg = "$file $msg"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
61
|
|
|
|
|
161
|
return $msg; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 file() |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns the filename of the error, as set by the caller. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 type() |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the type of the error. This will either be C, |
87
|
|
|
|
|
|
|
or C. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 line() |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns the line number of the error, or 0 if there isn't an applicable |
92
|
|
|
|
|
|
|
line number. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 column() |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the column number, or 0 if there isn't an applicable column |
97
|
|
|
|
|
|
|
number. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 text() |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns the text of the message. This does not include a type string, |
102
|
|
|
|
|
|
|
like "Info: ". |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
65
|
|
|
65
|
1
|
2778
|
sub file { my $self = shift; return $self->{_file} } |
|
65
|
|
|
|
|
193
|
|
107
|
116
|
|
|
116
|
1
|
2831
|
sub type { my $self = shift; return $self->{_type} } |
|
116
|
|
|
|
|
410
|
|
108
|
124
|
|
|
124
|
1
|
2417
|
sub line { my $self = shift; return $self->{_line} } |
|
124
|
|
|
|
|
269
|
|
109
|
122
|
|
|
122
|
1
|
2933
|
sub column { my $self = shift; return $self->{_column} } |
|
122
|
|
|
|
|
367
|
|
110
|
92
|
|
|
92
|
1
|
2791
|
sub text { my $self = shift; return $self->{_text} } |
|
92
|
|
|
|
|
246
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright 2005-2018 Andy Lester. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
118
|
|
|
|
|
|
|
it under the terms of the Artistic License v2.0. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Andy Lester, C<< >> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; # happy |