line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PRT::Command::IntroduceVariables; |
2
|
2
|
|
|
2
|
|
3472
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
81
|
|
4
|
2
|
|
|
2
|
|
593
|
use PPI; |
|
2
|
|
|
|
|
106961
|
|
|
2
|
|
|
|
|
220
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
4
|
|
|
4
|
0
|
17498
|
my ($class) = @_; |
8
|
4
|
|
|
|
|
49
|
bless {}, $class; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub parse_arguments { |
12
|
1
|
|
|
1
|
0
|
3
|
my ($self, @arguments) = @_; |
13
|
2
|
|
|
2
|
|
1410
|
use Data::Dumper; |
|
2
|
|
|
|
|
14706
|
|
|
2
|
|
|
|
|
614
|
|
14
|
1
|
|
|
|
|
3
|
@arguments; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub execute { |
18
|
1
|
|
|
1
|
0
|
550
|
my ($self, $file, $out) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
8
|
my $variables = $self->collect_variables($file); |
21
|
1
|
|
|
|
|
831
|
for my $variable (@$variables) { |
22
|
6
|
|
|
|
|
105
|
say $out $variable; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub collect_variables { |
27
|
2
|
|
|
2
|
0
|
12
|
my ($self, $file) = @_; |
28
|
2
|
|
|
|
|
25
|
my $document = PPI::Document->new($file); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
32559
|
my $knowns = {}; |
31
|
2
|
|
|
|
|
8
|
my $variables = []; |
32
|
2
|
|
|
|
|
15
|
my $tokens = $document->find('PPI::Token::Symbol'); |
33
|
2
|
50
|
|
|
|
6956
|
return [] unless $tokens; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
9
|
for my $token (@$tokens) { |
36
|
20
|
100
|
|
|
|
75
|
next if $knowns->{$token}++; |
37
|
|
|
|
|
|
|
|
38
|
12
|
|
|
|
|
70
|
push @$variables, $token->content; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
23
|
$variables; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |