line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::T5::Message; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
345
|
use 5.010001; |
|
25
|
|
|
|
|
72
|
|
4
|
25
|
|
|
25
|
|
466
|
use warnings; |
|
25
|
|
|
|
|
36
|
|
|
25
|
|
|
|
|
468
|
|
5
|
25
|
|
|
25
|
|
93
|
use strict; |
|
25
|
|
|
|
|
40
|
|
|
25
|
|
|
|
|
7846
|
|
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
|
5955
|
my $class = shift; |
29
|
|
|
|
|
|
|
|
30
|
179
|
|
|
|
|
194
|
my $file = shift; |
31
|
179
|
|
|
|
|
195
|
my $type = shift; |
32
|
179
|
|
100
|
|
|
335
|
my $line = shift || 0; |
33
|
179
|
|
100
|
|
|
299
|
my $column = shift || 0; |
34
|
179
|
|
|
|
|
203
|
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
|
|
|
|
|
527
|
my $self = { |
39
|
|
|
|
|
|
|
_file => $file, |
40
|
|
|
|
|
|
|
_type => $type, |
41
|
|
|
|
|
|
|
_line => $line, |
42
|
|
|
|
|
|
|
_column => $column, |
43
|
|
|
|
|
|
|
_text => $text, |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
179
|
|
|
|
|
248
|
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
|
15282
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
61
|
|
|
|
|
161
|
my %strings = ( |
61
|
|
|
|
|
|
|
1 => 'Info', |
62
|
|
|
|
|
|
|
2 => 'Warning', |
63
|
|
|
|
|
|
|
3 => 'Error', |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
61
|
|
|
|
|
101
|
my $msg = $strings{$self->type} . ': ' . $self->text; |
67
|
|
|
|
|
|
|
|
68
|
61
|
100
|
66
|
|
|
110
|
if ( $self->line && $self->column ) { |
69
|
59
|
|
|
|
|
88
|
$msg = sprintf( '(%d:%d) %s', $self->line, $self->column, $msg ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
61
|
|
100
|
|
|
124
|
my $file = $self->file // ''; |
73
|
61
|
100
|
|
|
|
124
|
if ( $file ne '' ) { |
74
|
24
|
|
|
|
|
44
|
$msg = "$file $msg"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
61
|
|
|
|
|
160
|
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
|
2438
|
sub file { my $self = shift; return $self->{_file} } |
|
65
|
|
|
|
|
158
|
|
107
|
116
|
|
|
116
|
1
|
2509
|
sub type { my $self = shift; return $self->{_type} } |
|
116
|
|
|
|
|
412
|
|
108
|
124
|
|
|
124
|
1
|
2082
|
sub line { my $self = shift; return $self->{_line} } |
|
124
|
|
|
|
|
286
|
|
109
|
122
|
|
|
122
|
1
|
2694
|
sub column { my $self = shift; return $self->{_column} } |
|
122
|
|
|
|
|
399
|
|
110
|
92
|
|
|
92
|
1
|
2444
|
sub text { my $self = shift; return $self->{_text} } |
|
92
|
|
|
|
|
257
|
|
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 |