line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::Subroutines::RemovePrototypes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
758
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
4
|
use Readonly; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
105
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
301
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Remove prototypes from subroutines}; |
15
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Remove prototypes from subroutines}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %map = ( |
20
|
|
|
|
|
|
|
sub => 1 |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
0
|
5
|
sub supported_parameters { return () } |
26
|
1
|
|
|
1
|
1
|
6
|
sub default_necessity { return $NECESSITY_HIGHEST } |
27
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
28
|
|
|
|
|
|
|
sub applies_to { |
29
|
|
|
|
|
|
|
return sub { |
30
|
|
|
|
|
|
|
$_[1]->isa('PPI::Token::Prototype') and |
31
|
|
|
|
|
|
|
$_[1]->sprevious_sibling and |
32
|
|
|
|
|
|
|
( exists $map{$_[1]->sprevious_sibling->content} or |
33
|
0
|
0
|
0
|
0
|
|
|
exists $map{$_[1]->sprevious_sibling->sprevious_sibling->content} ) |
|
|
|
0
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
0
|
1
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub transform { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$elem->remove unless $elem->content =~ /[a-zA-Z0-9]/; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::Subroutines::RemovePrototypes - Remove ($)-style prototypes on subroutines. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AFFILIATION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
63
|
|
|
|
|
|
|
distribution. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Perl6 now has proper function signatures, subroutine prototype are deprecated: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub foo($) { } --> sub foo { } |
71
|
|
|
|
|
|
|
sub foo($a) { } --> sub foo($a) { } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Transforms subroutines outside of comments, heredocs, strings and POD. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 CONFIGURATION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
88
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
############################################################################## |
93
|
|
|
|
|
|
|
# Local Variables: |
94
|
|
|
|
|
|
|
# mode: cperl |
95
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
96
|
|
|
|
|
|
|
# fill-column: 78 |
97
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
98
|
|
|
|
|
|
|
# c-indentation-style: bsd |
99
|
|
|
|
|
|
|
# End: |
100
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |