line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Babble::Plugin::Sigify; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
69321
|
use strictures 2; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
86
|
|
4
|
1
|
|
|
1
|
|
749
|
use Moo; |
|
1
|
|
|
|
|
7075
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub transform_to_plain { |
7
|
2
|
|
|
2
|
0
|
3106
|
my ($self, $top) = @_; |
8
|
|
|
|
|
|
|
my $tf = sub { |
9
|
2
|
|
|
2
|
|
6
|
my ($m) = @_; |
10
|
2
|
|
|
|
|
66
|
my $body = $m->submatches->{body}->text; |
11
|
2
|
|
|
|
|
10
|
$body =~ s/^\s+//; |
12
|
2
|
50
|
|
|
|
21
|
if ($body =~ s/^\{\s*my\s*(\([^\)]+\))\s*=\s*\@_\s*;/{/sm) { |
13
|
2
|
|
|
|
|
7
|
my $sig = $1; |
14
|
2
|
|
|
|
|
8
|
$body =~ s/^{\n\n/{\n/; |
15
|
2
|
|
|
|
|
42
|
$m->submatches->{body}->replace_text($sig.' '.$body); |
16
|
|
|
|
|
|
|
} |
17
|
2
|
|
|
|
|
13
|
}; |
18
|
2
|
|
|
|
|
16
|
$top->each_match_within('SubroutineDeclaration' => [ |
19
|
|
|
|
|
|
|
'sub \b (?&PerlOWS) (?&PerlOldQualifiedIdentifier) (?&PerlOWS)', |
20
|
|
|
|
|
|
|
'(?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+', |
21
|
|
|
|
|
|
|
[ body => '(?&PerlBlock)' ], '(?&PerlOWS)' |
22
|
|
|
|
|
|
|
] => $tf); |
23
|
2
|
|
|
|
|
16
|
$top->each_match_within('AnonymousSubroutine' => [ |
24
|
|
|
|
|
|
|
'sub \b (?&PerlOWS)', |
25
|
|
|
|
|
|
|
'(?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+', |
26
|
|
|
|
|
|
|
[ body => '(?&PerlBlock)' ], '(?&PerlOWS)' |
27
|
|
|
|
|
|
|
] => $tf); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Babble::Plugin::Sigify - Plugin to convert @_ unpacking to signature syntax |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SEE ALSO |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
L<signatures feature|feature/"The 'signatures' feature"> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |