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