line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Transformer::Instances::RewriteCreation; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
715
|
use 5.006001; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
5
|
use Readonly; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :severities }; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
9
|
1
|
|
|
|
|
66
|
use Perl::ToPerl6::Utils::PPI qw{ |
10
|
|
|
|
|
|
|
is_ppi_token_word |
11
|
|
|
|
|
|
|
dscanf |
12
|
|
|
|
|
|
|
make_ppi_structure_list |
13
|
|
|
|
|
|
|
remove_trailing_whitespace |
14
|
1
|
|
|
1
|
|
113
|
}; |
|
1
|
|
|
|
|
2
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use base 'Perl::ToPerl6::Transformer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
459
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Transform 'new Foo()' to 'Foo->new()'}; |
21
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Transform 'new Foo()' to 'Foo->new()'}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Run before '->' --> '.' conversion so we don't have to worry. |
27
|
|
|
|
|
|
|
# |
28
|
1
|
|
|
1
|
0
|
4
|
sub run_before { return 'Operators::FormatOperators' } |
29
|
1
|
|
|
1
|
0
|
3
|
sub supported_parameters { return () } |
30
|
1
|
|
|
1
|
1
|
4
|
sub default_necessity { return $NECESSITY_HIGHEST } |
31
|
0
|
|
|
0
|
1
|
|
sub default_themes { return qw( core ) } |
32
|
|
|
|
|
|
|
sub applies_to { |
33
|
|
|
|
|
|
|
return sub { |
34
|
0
|
0
|
|
0
|
|
|
dscanf('new %W %L')->(@_) || |
35
|
|
|
|
|
|
|
dscanf('new %W %s')->(@_) |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
0
|
1
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub transform { |
42
|
0
|
|
|
0
|
0
|
|
my ($self, $elem, $doc) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $token = $elem->clone; |
45
|
0
|
0
|
|
|
|
|
if ( $elem->snext_sibling->snext_sibling->isa('PPI::Token::Quote') ) { |
46
|
0
|
|
|
|
|
|
my $new_list = make_ppi_structure_list; |
47
|
0
|
|
|
|
|
|
my $new_statement = PPI::Statement->new; |
48
|
0
|
|
|
|
|
|
$new_list->add_element($new_statement); |
49
|
0
|
|
|
|
|
|
$new_statement->add_element( |
50
|
|
|
|
|
|
|
$elem->snext_sibling->snext_sibling->clone |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
0
|
|
|
|
while ( $token and $token->next_sibling ) { |
54
|
0
|
0
|
|
|
|
|
last if $token->content eq ','; |
55
|
0
|
|
|
|
|
|
$new_statement->add_element($token->clone); |
56
|
0
|
|
|
|
|
|
$token = $token->next_sibling; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
$elem->snext_sibling->snext_sibling->remove; |
59
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after($new_list); |
60
|
0
|
|
|
|
|
|
remove_trailing_whitespace($elem->snext_sibling->snext_sibling); |
61
|
|
|
|
|
|
|
} |
62
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after($token); |
63
|
0
|
|
|
|
|
|
$elem->snext_sibling->insert_after( |
64
|
|
|
|
|
|
|
PPI::Token::Operator->new('->') |
65
|
|
|
|
|
|
|
); |
66
|
0
|
|
|
|
|
|
remove_trailing_whitespace($elem); |
67
|
0
|
|
|
|
|
|
$elem->delete; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $self->transformation( $DESC, $EXPL, $elem ); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Perl::ToPerl6::Transformer::Instances::RewriteCreation - Indirect object notation no longer allowed. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AFFILIATION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This Transformer is part of the core L<Perl::ToPerl6|Perl::ToPerl6> |
88
|
|
|
|
|
|
|
distribution. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Perl6 no longer supports Perl5-style indirect object notation. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
new Foo(); --> Foo.new(); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Transforms 'new' statements outside of comments, heredocs, strings and POD. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 CONFIGURATION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This Transformer is not configurable except for the standard options. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Jeffrey Goff <drforr@pobox.com> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright (c) 2015 Jeffrey Goff |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
112
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
############################################################################## |
117
|
|
|
|
|
|
|
# Local Variables: |
118
|
|
|
|
|
|
|
# mode: cperl |
119
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
120
|
|
|
|
|
|
|
# fill-column: 78 |
121
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
122
|
|
|
|
|
|
|
# c-indentation-style: bsd |
123
|
|
|
|
|
|
|
# End: |
124
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |