line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::GitGrepPerlStatement::StatementFinder; |
2
|
1
|
|
|
1
|
|
12
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
527
|
use PPI; |
|
1
|
|
|
|
|
120161
|
|
|
1
|
|
|
|
|
46
|
|
6
|
1
|
|
|
1
|
|
12
|
use List::MoreUtils qw(any); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
7
|
1
|
|
|
1
|
|
1370
|
use Term::ANSIColor qw(colored); |
|
1
|
|
|
|
|
6371
|
|
|
1
|
|
|
|
|
805
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
0
|
|
my ($class, $word) = @_; |
11
|
0
|
|
|
|
|
|
bless { |
12
|
|
|
|
|
|
|
word => $word, |
13
|
|
|
|
|
|
|
docs => [], |
14
|
|
|
|
|
|
|
}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub word { |
18
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
19
|
0
|
|
|
|
|
|
$self->{word}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub search { |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $file) = @_; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $doc = PPI::Document->new($file); |
26
|
0
|
0
|
|
|
|
|
return unless $doc; |
27
|
0
|
|
|
|
|
|
push @{$self->{docs}}, $doc; |
|
0
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $statements = $doc->find('PPI::Statement'); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
grep { |
32
|
0
|
|
|
|
|
|
my $tokens = [ $_->children ]; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
any { |
35
|
0
|
|
|
0
|
|
|
$_ eq $self->word; |
36
|
0
|
|
|
|
|
|
} @$tokens; |
37
|
|
|
|
|
|
|
} @$statements; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub flush { |
41
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
42
|
0
|
|
|
|
|
|
$self->{docs} = []; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub highlight_style { |
46
|
0
|
|
|
0
|
0
|
|
['red']; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub highlight { |
50
|
0
|
|
|
0
|
0
|
|
my ($self, $statement) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
join '', map { |
53
|
0
|
0
|
|
|
|
|
if ($_ eq $self->word) { |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
colored($self->highlight_style, $_); |
55
|
|
|
|
|
|
|
} else { |
56
|
0
|
|
|
|
|
|
$_; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} $statement->children; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |