line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::CompoundStatements::RenameForeach; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
11194
|
use 5.006001; |
|
17
|
|
|
|
|
45
|
|
4
|
17
|
|
|
17
|
|
87
|
use strict; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
375
|
|
5
|
17
|
|
|
17
|
|
70
|
use warnings; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
557
|
|
6
|
17
|
|
|
17
|
|
86
|
use Readonly; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
920
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
91
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
942
|
|
9
|
17
|
|
|
17
|
|
4367
|
use Perl::ToPerl6::Utils::PPI qw{ is_ppi_statement_compound }; |
|
17
|
|
|
|
|
28
|
|
|
17
|
|
|
|
|
827
|
|
10
|
|
|
|
|
|
|
|
11
|
17
|
|
|
17
|
|
85
|
use base 'Perl::ToPerl6::Transformer'; |
|
17
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
4781
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform 'foreach' to 'for'}; |
18
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{foreach() is now nmaed for()}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %map = ( |
23
|
|
|
|
|
|
|
foreach => 'for', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
27
|
|
|
|
|
|
|
|
28
|
40
|
|
|
40
|
0
|
1370
|
sub supported_parameters { return () } |
29
|
29
|
|
|
29
|
1
|
122
|
sub default_severity { return $SEVERITY_HIGHEST } |
30
|
25
|
|
|
25
|
1
|
88
|
sub default_themes { return qw(core bugs) } |
31
|
|
|
|
|
|
|
sub applies_to { |
32
|
|
|
|
|
|
|
return sub { |
33
|
61
|
|
|
61
|
|
720
|
is_ppi_statement_compound($_[1], %map) |
34
|
|
|
|
|
|
|
} |
35
|
4
|
|
|
4
|
1
|
21
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub transform { |
40
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $old_content = $elem->schild(0)->content; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$elem->schild(0)->set_content($map{$old_content}); |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::CompoundStatements::RenameForeach - Rename 'foreach' to 'for' |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AFFILIATION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
65
|
|
|
|
|
|
|
distribution. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Perl6 no longer uses 'foreach': |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
foreach(1) { } --> for(1) { } |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 CONFIGURATION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHOR |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
87
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
############################################################################## |
92
|
|
|
|
|
|
|
# Local Variables: |
93
|
|
|
|
|
|
|
# mode: cperl |
94
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
95
|
|
|
|
|
|
|
# fill-column: 78 |
96
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
97
|
|
|
|
|
|
|
# c-indentation-style: bsd |
98
|
|
|
|
|
|
|
# End: |
99
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |