| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::Packages::FormatPackageDeclarations; |
|
2
|
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
12113
|
use 5.006001; |
|
|
17
|
|
|
|
|
53
|
|
|
4
|
17
|
|
|
17
|
|
83
|
use strict; |
|
|
17
|
|
|
|
|
30
|
|
|
|
17
|
|
|
|
|
406
|
|
|
5
|
17
|
|
|
17
|
|
69
|
use warnings; |
|
|
17
|
|
|
|
|
33
|
|
|
|
17
|
|
|
|
|
436
|
|
|
6
|
17
|
|
|
17
|
|
79
|
use Readonly; |
|
|
17
|
|
|
|
|
29
|
|
|
|
17
|
|
|
|
|
962
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
98
|
use Perl::ToPerl6::Utils qw{ :characters :severities }; |
|
|
17
|
|
|
|
|
38
|
|
|
|
17
|
|
|
|
|
1010
|
|
|
9
|
17
|
|
|
|
|
1153
|
use Perl::ToPerl6::Utils::PPI qw{ |
|
10
|
|
|
|
|
|
|
is_ppi_token_word |
|
11
|
|
|
|
|
|
|
is_package_boundary |
|
12
|
|
|
|
|
|
|
make_ppi_structure_block |
|
13
|
17
|
|
|
17
|
|
4766
|
}; |
|
|
17
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
17
|
|
|
17
|
|
98
|
use base 'Perl::ToPerl6::Transformer'; |
|
|
17
|
|
|
|
|
42
|
|
|
|
17
|
|
|
|
|
4932
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform 'package' declaration into 'class'}; |
|
22
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{The Perl6 equivalent of packages are classes.}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
25
|
|
|
|
|
|
|
|
|
26
|
40
|
|
|
40
|
0
|
1961
|
sub supported_parameters { return () } |
|
27
|
29
|
|
|
29
|
1
|
112
|
sub default_severity { return $SEVERITY_HIGHEST } |
|
28
|
25
|
|
|
25
|
1
|
89
|
sub default_themes { return qw(core bugs) } |
|
29
|
4
|
|
|
4
|
1
|
10
|
sub applies_to { 'PPI::Document' } |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Just make this a document-level processor for the time being. |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
sub transform { |
|
36
|
4
|
|
|
4
|
0
|
9
|
my ($self, $elem, $doc) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
12
|
my $ref = $doc->find('PPI::Statement::Package'); |
|
39
|
4
|
100
|
66
|
|
|
16
|
if ( $ref and @{ $ref } ) { |
|
|
1
|
|
|
|
|
7
|
|
|
40
|
1
|
|
|
|
|
2
|
my @package = @{ $ref }; |
|
|
1
|
|
|
|
|
3
|
|
|
41
|
1
|
|
|
|
|
4
|
for my $package ( @package ) { |
|
42
|
1
|
|
|
|
|
15
|
$package->schild(0)->set_content('unit class'); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# if ( $package->schild(2) and |
|
45
|
|
|
|
|
|
|
# $package->schild(2)->isa('PPI::Token::Structure') and |
|
46
|
|
|
|
|
|
|
# $package->schild(2)->content eq ';' ) { |
|
47
|
|
|
|
|
|
|
# |
|
48
|
|
|
|
|
|
|
# my $new_block = make_ppi_structure_block; |
|
49
|
|
|
|
|
|
|
# my $new_statement = PPI::Statement->new; |
|
50
|
|
|
|
|
|
|
# $new_block->add_element($new_statement); |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# my $token = $package->next_sibling; |
|
53
|
|
|
|
|
|
|
# while ( $token and $token->next_sibling ) { |
|
54
|
|
|
|
|
|
|
# last if is_package_boundary($token); |
|
55
|
|
|
|
|
|
|
# $new_statement->add_element($token->clone); |
|
56
|
|
|
|
|
|
|
# $token = $token->next_sibling; |
|
57
|
|
|
|
|
|
|
# } |
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
# my $point = $package->next_sibling; |
|
60
|
|
|
|
|
|
|
# while ( $point and |
|
61
|
|
|
|
|
|
|
# not is_package_boundary($point) ) { |
|
62
|
|
|
|
|
|
|
# my $temp = $point->next_sibling; |
|
63
|
|
|
|
|
|
|
# $point->remove; |
|
64
|
|
|
|
|
|
|
# $point = $temp; |
|
65
|
|
|
|
|
|
|
# } |
|
66
|
|
|
|
|
|
|
# $package->last_element->insert_before($new_block); |
|
67
|
|
|
|
|
|
|
# } |
|
68
|
|
|
|
|
|
|
} |
|
69
|
1
|
|
|
|
|
43
|
return $self->transformation( $DESC, $EXPL, $elem ); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
7
|
return; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::Packages::FormatPackageDeclarations - Format 'package Foo;' declarations |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
|
91
|
|
|
|
|
|
|
distribution. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The Perl6 equivalent of a Perl5 package is 'class'. Older Perl5 source uses C<package Foo;> while some more modern source uses C<package Foo { .. }> to delineate package boundaries: |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
package Foo; --> class Foo { ... } |
|
99
|
|
|
|
|
|
|
package # ? |
|
100
|
|
|
|
|
|
|
Foo; --> class\n# ?\nFoo { ... } |
|
101
|
|
|
|
|
|
|
package Foo { ... } --> class Foo { ... } |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Other transformers will be responsible for ensuring that perl5 classes inherit correctly. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
118
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
############################################################################## |
|
123
|
|
|
|
|
|
|
# Local Variables: |
|
124
|
|
|
|
|
|
|
# mode: cperl |
|
125
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
|
126
|
|
|
|
|
|
|
# fill-column: 78 |
|
127
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
128
|
|
|
|
|
|
|
# c-indentation-style: bsd |
|
129
|
|
|
|
|
|
|
# End: |
|
130
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |