line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Parser::ClassLoad; |
2
|
|
|
|
|
|
|
|
3
|
82
|
|
|
82
|
|
1471
|
use strict; |
|
82
|
|
|
|
|
152
|
|
|
82
|
|
|
|
|
1792
|
|
4
|
82
|
|
|
82
|
|
307
|
use warnings; |
|
82
|
|
|
|
|
139
|
|
|
82
|
|
|
|
|
1453
|
|
5
|
82
|
|
|
82
|
|
361
|
use Perl::PrereqScanner::NotQuiteLite::Util; |
|
82
|
|
|
|
|
137
|
|
|
82
|
|
|
|
|
57537
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my %known_functions = map {$_ => 1} qw/ |
8
|
|
|
|
|
|
|
load_class try_load_class load_optional_class |
9
|
|
|
|
|
|
|
load_first_existing_class |
10
|
|
|
|
|
|
|
/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub register { return { |
13
|
81
|
|
|
81
|
0
|
386
|
use => { |
14
|
|
|
|
|
|
|
'Class::Load' => 'parse_class_load_args', |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
}} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register_fqfn { return { |
19
|
692
|
|
|
692
|
0
|
1949
|
map { "Class::Load::".$_ => "parse_".$_."_args" } |
|
2768
|
|
|
|
|
8554
|
|
20
|
|
|
|
|
|
|
keys %known_functions |
21
|
|
|
|
|
|
|
}} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parse_class_load_args { |
24
|
11
|
|
|
11
|
0
|
30
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
|
|
31
|
my $tokens = convert_string_tokens($raw_tokens); |
27
|
11
|
50
|
|
|
|
35
|
if (is_version($tokens->[0])) { |
28
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
11
|
|
|
|
|
26
|
for my $token (@$tokens) { |
32
|
21
|
100
|
|
|
|
64
|
next if ref $token; |
33
|
|
|
|
|
|
|
|
34
|
10
|
100
|
|
|
|
30
|
if ($known_functions{$token}) { |
|
|
50
|
|
|
|
|
|
35
|
7
|
|
|
|
|
37
|
$c->register_keyword_parser( |
36
|
|
|
|
|
|
|
$token, |
37
|
|
|
|
|
|
|
[$class, 'parse_'.$token.'_args', $used_module], |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} elsif ($token eq ':all') { |
40
|
3
|
|
|
|
|
11
|
for my $func (keys %known_functions) { |
41
|
12
|
|
|
|
|
35
|
$c->register_keyword_parser( |
42
|
|
|
|
|
|
|
$func, |
43
|
|
|
|
|
|
|
[$class, 'parse_'.$func.'_args', $used_module], |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub parse_load_class_args { |
51
|
6
|
|
|
6
|
0
|
17
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
14
|
my $tokens = convert_string_tokens($raw_tokens); |
54
|
6
|
|
|
|
|
18
|
shift @$tokens; # function |
55
|
6
|
|
|
|
|
15
|
my ($module, undef, $options) = @$tokens; |
56
|
6
|
|
|
|
|
17
|
my $version = 0; |
57
|
6
|
100
|
66
|
|
|
17
|
if (ref $options and $options->[1] eq '{}') { |
58
|
1
|
|
|
|
|
4
|
my $tokens_in_hashref = convert_string_tokens($options->[0]); |
59
|
1
|
|
|
|
|
6
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
60
|
1
|
50
|
33
|
|
|
7
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
$version = $value; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
6
|
|
|
|
|
19
|
$c->add_conditional($module => $version); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub parse_try_load_class_args { |
69
|
3
|
|
|
3
|
0
|
9
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
70
|
|
|
|
|
|
|
|
71
|
3
|
|
|
|
|
9
|
my $tokens = convert_string_tokens($raw_tokens); |
72
|
3
|
|
|
|
|
5
|
shift @$tokens; # function |
73
|
3
|
|
|
|
|
7
|
my ($module, undef, $options) = @$tokens; |
74
|
3
|
|
|
|
|
6
|
my $version = 0; |
75
|
3
|
100
|
66
|
|
|
12
|
if (ref $options and $options->[1] eq '{}') { |
76
|
1
|
|
|
|
|
3
|
my $tokens_in_hashref = convert_string_tokens($options->[0]); |
77
|
1
|
|
|
|
|
5
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
78
|
1
|
50
|
33
|
|
|
7
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
79
|
1
|
|
|
|
|
5
|
$version = $value; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
3
|
|
|
|
|
11
|
$c->add_suggestion($module => $version); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub parse_load_optional_class_args { |
87
|
0
|
|
|
0
|
0
|
0
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
$class->parse_try_load_class_args($c, $used_module, $raw_tokens); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub parse_load_first_existing_class_args { |
93
|
2
|
|
|
2
|
0
|
5
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
94
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
8
|
my $tokens = convert_string_tokens($raw_tokens); |
96
|
2
|
|
|
|
|
4
|
shift @$tokens; # function |
97
|
2
|
|
|
|
|
4
|
my ($module, $version); |
98
|
2
|
|
|
|
|
4
|
for my $token (@$tokens) { |
99
|
14
|
100
|
|
|
|
24
|
if (is_module_name($token)) { |
100
|
5
|
100
|
|
|
|
12
|
if ($module) { |
101
|
3
|
|
|
|
|
9
|
$c->add_suggestion($module => $version); |
102
|
|
|
|
|
|
|
} |
103
|
5
|
|
|
|
|
139
|
$module = $token; |
104
|
5
|
|
|
|
|
8
|
$version = 0; |
105
|
5
|
|
|
|
|
8
|
next; |
106
|
|
|
|
|
|
|
} |
107
|
9
|
100
|
50
|
|
|
44
|
if (ref $token and ($token->[1] || '') eq '{}') { |
|
|
|
66
|
|
|
|
|
108
|
2
|
|
|
|
|
8
|
my $tokens_in_hashref = convert_string_tokens($token->[0]); |
109
|
2
|
|
|
|
|
8
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
110
|
2
|
50
|
33
|
|
|
11
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
111
|
2
|
|
|
|
|
8
|
$version = $value; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
2
|
50
|
|
|
|
4
|
if ($module) { |
117
|
2
|
|
|
|
|
6
|
$c->add_suggestion($module => $version); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |