line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Parser::AnyMoose; |
2
|
|
|
|
|
|
|
|
3
|
83
|
|
|
83
|
|
1406
|
use strict; |
|
83
|
|
|
|
|
186
|
|
|
83
|
|
|
|
|
2875
|
|
4
|
83
|
|
|
83
|
|
429
|
use warnings; |
|
83
|
|
|
|
|
174
|
|
|
83
|
|
|
|
|
1976
|
|
5
|
83
|
|
|
83
|
|
1072
|
use Perl::PrereqScanner::NotQuiteLite::Util; |
|
83
|
|
|
|
|
173
|
|
|
83
|
|
|
|
|
57442
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub register {{ |
8
|
82
|
|
|
82
|
0
|
521
|
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
|
23
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
|
|
27
|
my $tokens = convert_string_tokens($raw_tokens); |
20
|
7
|
50
|
|
|
|
27
|
if (is_version($tokens->[0])) { |
21
|
0
|
|
|
|
|
0
|
$c->add($used_module => shift @$tokens); |
22
|
|
|
|
|
|
|
} |
23
|
7
|
|
|
|
|
21
|
while(my $token = shift @$tokens) { |
24
|
18
|
100
|
|
|
|
231
|
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
|
|
|
|
14
|
$c->add_recommendation($module => 0) if is_module_name($module); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$c->register_keyword_parser( |
33
|
7
|
|
|
|
|
47
|
'extends', |
34
|
|
|
|
|
|
|
[$class, 'parse_extends_args', $used_module], |
35
|
|
|
|
|
|
|
); |
36
|
7
|
|
|
|
|
31
|
$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
|
18
|
sub parse_extends_args { shift->_parse_loader_args(@_) } |
50
|
1
|
|
|
1
|
0
|
5
|
sub parse_with_args { shift->_parse_loader_args(@_) } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _parse_loader_args { |
53
|
5
|
|
|
5
|
|
16
|
my ($class, $c, $used_module, $raw_tokens) = @_; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
17
|
my $tokens = convert_string_tokens($raw_tokens); |
56
|
5
|
|
|
|
|
12
|
shift @$tokens; # discard extends, with; |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
10
|
my $prev; |
59
|
|
|
|
|
|
|
my $saw_any_moose; |
60
|
5
|
|
|
|
|
21
|
while(my $token = shift @$tokens) { |
61
|
15
|
100
|
|
|
|
109
|
if (!ref $token) { |
62
|
4
|
100
|
|
|
|
10
|
if ($saw_any_moose) { |
63
|
2
|
|
|
|
|
6
|
my $module = "Mouse$token"; |
64
|
2
|
|
|
|
|
9
|
$c->add_recommendation($module => 0); |
65
|
2
|
|
|
|
|
66
|
$prev = $module; |
66
|
|
|
|
|
|
|
} else { |
67
|
2
|
|
|
|
|
11
|
$c->add($token => 0); |
68
|
2
|
|
|
|
|
69
|
$prev = $token; |
69
|
|
|
|
|
|
|
} |
70
|
4
|
|
|
|
|
13
|
next; |
71
|
|
|
|
|
|
|
} |
72
|
11
|
100
|
|
|
|
31
|
if ($token->[0] eq 'any_moose') { |
73
|
3
|
|
|
|
|
5
|
$saw_any_moose = 1; |
74
|
3
|
|
|
|
|
10
|
next; |
75
|
|
|
|
|
|
|
} |
76
|
8
|
|
50
|
|
|
21
|
my $desc = $token->[1] || ''; |
77
|
8
|
50
|
|
|
|
21
|
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
|
|
|
49
|
if ($saw_any_moose and $desc eq '()') { |
97
|
2
|
|
|
|
|
7
|
my $tokens_in_parentheses = convert_string_tokens($token->[0]); |
98
|
2
|
|
|
|
|
8
|
for my $token_in_parentheses (@$tokens_in_parentheses) { |
99
|
2
|
50
|
|
|
|
7
|
next if ref $token_in_parentheses; |
100
|
2
|
|
|
|
|
6
|
my $module = "Mouse$token_in_parentheses"; |
101
|
2
|
50
|
|
|
|
10
|
$c->add_recommendation($module => 0) if is_module_name($module); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
__END__ |