line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Parser::ClassLoad; |
2
|
|
|
|
|
|
|
|
3
|
83
|
|
|
83
|
|
1413
|
use strict; |
|
83
|
|
|
|
|
178
|
|
|
83
|
|
|
|
|
2188
|
|
4
|
83
|
|
|
83
|
|
399
|
use warnings; |
|
83
|
|
|
|
|
175
|
|
|
83
|
|
|
|
|
1827
|
|
5
|
83
|
|
|
83
|
|
399
|
use Perl::PrereqScanner::NotQuiteLite::Util; |
|
83
|
|
|
|
|
179
|
|
|
83
|
|
|
|
|
70840
|
|
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
|
82
|
|
|
82
|
0
|
461
|
use => { |
14
|
|
|
|
|
|
|
'Class::Load' => 'parse_class_load_args', |
15
|
|
|
|
|
|
|
}, |
16
|
|
|
|
|
|
|
}} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register_fqfn { return { |
19
|
734
|
|
|
734
|
0
|
2361
|
map { "Class::Load::".$_ => "parse_".$_."_args" } |
|
2936
|
|
|
|
|
11284
|
|
20
|
|
|
|
|
|
|
keys %known_functions |
21
|
|
|
|
|
|
|
}} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub parse_class_load_args { |
24
|
11
|
|
|
11
|
0
|
28
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
|
|
33
|
my $tokens = convert_string_tokens($raw_tokens); |
27
|
11
|
50
|
|
|
|
36
|
if (is_version($tokens->[0])) { |
28
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
11
|
|
|
|
|
29
|
for my $token (@$tokens) { |
32
|
21
|
100
|
|
|
|
81
|
next if ref $token; |
33
|
|
|
|
|
|
|
|
34
|
10
|
100
|
|
|
|
32
|
if ($known_functions{$token}) { |
|
|
50
|
|
|
|
|
|
35
|
7
|
|
|
|
|
74
|
$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
|
|
|
|
|
45
|
$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
|
19
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
20
|
my $tokens = convert_string_tokens($raw_tokens); |
54
|
6
|
|
|
|
|
11
|
shift @$tokens; # function |
55
|
6
|
|
|
|
|
15
|
my ($module, undef, $options) = @$tokens; |
56
|
6
|
|
|
|
|
10
|
my $version = 0; |
57
|
6
|
100
|
66
|
|
|
24
|
if (ref $options and $options->[1] eq '{}') { |
58
|
1
|
|
|
|
|
4
|
my $tokens_in_hashref = convert_string_tokens($options->[0]); |
59
|
1
|
|
|
|
|
9
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
60
|
1
|
50
|
33
|
|
|
22
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
61
|
1
|
|
|
|
|
5
|
$version = $value; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
6
|
|
|
|
|
21
|
$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
|
|
|
|
|
8
|
shift @$tokens; # function |
73
|
3
|
|
|
|
|
7
|
my ($module, undef, $options) = @$tokens; |
74
|
3
|
|
|
|
|
7
|
my $version = 0; |
75
|
3
|
100
|
66
|
|
|
14
|
if (ref $options and $options->[1] eq '{}') { |
76
|
1
|
|
|
|
|
6
|
my $tokens_in_hashref = convert_string_tokens($options->[0]); |
77
|
1
|
|
|
|
|
9
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
78
|
1
|
50
|
33
|
|
|
9
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
79
|
1
|
|
|
|
|
5
|
$version = $value; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
3
|
|
|
|
|
12
|
$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
|
7
|
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
|
|
|
|
|
6
|
my ($module, $version); |
98
|
2
|
|
|
|
|
6
|
for my $token (@$tokens) { |
99
|
14
|
100
|
|
|
|
36
|
if (is_module_name($token)) { |
100
|
5
|
100
|
|
|
|
13
|
if ($module) { |
101
|
3
|
|
|
|
|
10
|
$c->add_suggestion($module => $version); |
102
|
|
|
|
|
|
|
} |
103
|
5
|
|
|
|
|
164
|
$module = $token; |
104
|
5
|
|
|
|
|
10
|
$version = 0; |
105
|
5
|
|
|
|
|
12
|
next; |
106
|
|
|
|
|
|
|
} |
107
|
9
|
100
|
50
|
|
|
48
|
if (ref $token and ($token->[1] || '') eq '{}') { |
|
|
|
66
|
|
|
|
|
108
|
2
|
|
|
|
|
9
|
my $tokens_in_hashref = convert_string_tokens($token->[0]); |
109
|
2
|
|
|
|
|
11
|
while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { |
110
|
2
|
50
|
33
|
|
|
15
|
if (ref $key and $key->[0] eq '-version' and is_version($value)) { |
|
|
|
33
|
|
|
|
|
111
|
2
|
|
|
|
|
10
|
$version = $value; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
2
|
50
|
|
|
|
6
|
if ($module) { |
117
|
2
|
|
|
|
|
8
|
$c->add_suggestion($module => $version); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |