line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Parser::AnyMoose; |
2
|
|
|
|
|
|
|
|
3
|
82
|
|
|
82
|
|
1238
|
use strict; |
|
82
|
|
|
|
|
187
|
|
|
82
|
|
|
|
|
2034
|
|
4
|
82
|
|
|
82
|
|
364
|
use warnings; |
|
82
|
|
|
|
|
142
|
|
|
82
|
|
|
|
|
1590
|
|
5
|
82
|
|
|
82
|
|
965
|
use Perl::PrereqScanner::NotQuiteLite::Util; |
|
82
|
|
|
|
|
169
|
|
|
82
|
|
|
|
|
51896
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register {{ |
8
|
81
|
|
|
81
|
0
|
463
|
use => { |
9
|
|
|
|
|
|
|
'Any::Moose' => 'parse_any_moose_args', |
10
|
|
|
|
|
|
|
}, |
11
|
|
|
|
|
|
|
no => { |
12
|
|
|
|
|
|
|
'Any::Moose' => 'remove_extends_and_with', |
13
|
|
|
|
|
|
|
}, |
14
|
|
|
|
|
|
|
}} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub parse_any_moose_args { |
17
|
7
|
|
|
7
|
0
|
29
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
|
|
30
|
my $tokens = convert_string_tokens($raw_tokens); |
20
|
7
|
50
|
|
|
|
30
|
if (is_version($tokens->[0])) { |
21
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
22
|
|
|
|
|
|
|
} |
23
|
7
|
|
|
|
|
98
|
while(my $token = shift @$tokens) { |
24
|
18
|
100
|
|
|
|
209
|
next if ref $token; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# As Any::Moose falls back to Mouse, it's nice to have |
27
|
|
|
|
|
|
|
# a Mouse variant, but that should not be required. |
28
|
5
|
|
|
|
|
13
|
my $module = "Mouse$token"; |
29
|
5
|
50
|
|
|
|
15
|
$c->add_recommendation($module => 0) if is_module_name($module); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$c->register_keyword_parser( |
33
|
7
|
|
|
|
|
49
|
'extends', |
34
|
|
|
|
|
|
|
[$class, 'parse_extends_args', $used_module], |
35
|
|
|
|
|
|
|
); |
36
|
7
|
|
|
|
|
33
|
$c->register_keyword_parser( |
37
|
|
|
|
|
|
|
'with', |
38
|
|
|
|
|
|
|
[$class, 'parse_with_args', $used_module], |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub remove_extends_and_with { |
43
|
0
|
|
|
0
|
0
|
0
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
$c->remove_keyword('extends'); |
46
|
0
|
|
|
|
|
0
|
$c->remove_keyword('with'); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
4
|
0
|
25
|
sub parse_extends_args { shift->_parse_loader_args(@_) } |
50
|
1
|
|
|
1
|
0
|
4
|
sub parse_with_args { shift->_parse_loader_args(@_) } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _parse_loader_args { |
53
|
5
|
|
|
5
|
|
15
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
22
|
my $tokens = convert_string_tokens($raw_tokens); |
56
|
5
|
|
|
|
|
15
|
shift @$tokens; # discard extends, with; |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
11
|
my $prev; |
59
|
|
|
|
|
|
|
my $saw_any_moose; |
60
|
5
|
|
|
|
|
24
|
while(my $token = shift @$tokens) { |
61
|
15
|
100
|
|
|
|
176
|
if (!ref $token) { |
62
|
4
|
100
|
|
|
|
9
|
if ($saw_any_moose) { |
63
|
2
|
|
|
|
|
5
|
my $module = "Mouse$token"; |
64
|
2
|
|
|
|
|
9
|
$c->add_recommendation($module => 0); |
65
|
2
|
|
|
|
|
61
|
$prev = $module; |
66
|
|
|
|
|
|
|
} else { |
67
|
2
|
|
|
|
|
11
|
$c->add($token => 0); |
68
|
2
|
|
|
|
|
65
|
$prev = $token; |
69
|
|
|
|
|
|
|
} |
70
|
4
|
|
|
|
|
12
|
next; |
71
|
|
|
|
|
|
|
} |
72
|
11
|
100
|
|
|
|
31
|
if ($token->[0] eq 'any_moose') { |
73
|
3
|
|
|
|
|
8
|
$saw_any_moose = 1; |
74
|
3
|
|
|
|
|
10
|
next; |
75
|
|
|
|
|
|
|
} |
76
|
8
|
|
50
|
|
|
23
|
my $desc = $token->[1] || ''; |
77
|
8
|
50
|
|
|
|
27
|
if ($desc eq '{}') { |
78
|
0
|
0
|
|
|
|
0
|
my @hash_tokens = @{$token->[0] || []}; |
|
0
|
|
|
|
|
0
|
|
79
|
0
|
|
|
|
|
0
|
for(my $i = 0, my $len = @hash_tokens; $i < $len; $i++) { |
80
|
0
|
0
|
0
|
|
|
0
|
if ($hash_tokens[$i][0] eq '-version' and $i < $len - 2) { |
81
|
0
|
|
|
|
|
0
|
my $maybe_version_token = $hash_tokens[$i + 2]; |
82
|
0
|
|
|
|
|
0
|
my $maybe_version = $maybe_version_token->[0]; |
83
|
0
|
0
|
|
|
|
0
|
if (ref $maybe_version) { |
84
|
0
|
|
|
|
|
0
|
$maybe_version = $maybe_version->[0]; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
0
|
0
|
|
|
0
|
if ($prev and is_version($maybe_version)) { |
87
|
0
|
0
|
|
|
|
0
|
if ($saw_any_moose) { |
88
|
0
|
|
|
|
|
0
|
$c->add_recommendation($prev => $maybe_version); |
89
|
|
|
|
|
|
|
} else { |
90
|
0
|
|
|
|
|
0
|
$c->add($prev => $maybe_version); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
8
|
100
|
100
|
|
|
96
|
if ($saw_any_moose and $desc eq '()') { |
97
|
2
|
|
|
|
|
8
|
my $tokens_in_parentheses = convert_string_tokens($token->[0]); |
98
|
2
|
|
|
|
|
9
|
for my $token_in_parentheses (@$tokens_in_parentheses) { |
99
|
2
|
50
|
|
|
|
8
|
next if ref $token_in_parentheses; |
100
|
2
|
|
|
|
|
8
|
my $module = "Mouse$token_in_parentheses"; |
101
|
2
|
50
|
|
|
|
9
|
$c->add_recommendation($module => 0) if is_module_name($module); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |