| 1 | package PLS::Parser::Index; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 15 | ▶ | no warnings 'File::Find'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use File::stat; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 15 | ▶ | use IO::Async::Function; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 15 | ▶ | use IO::Async::Loop; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 15 | ▶ | use List::Util qw(any); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 15 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 15 | ▶ | use PPR; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 15 | ▶ | use Path::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 15 | ▶ | use Storable; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 15 | ▶ | use Time::Piece; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 15 | ▶ | use URI::file; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | PLS::Parser::Index | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | This class caches and stores indexed data about the workspace. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | It is used for quick searching of subroutines and packages by name. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 91 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 91 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 91 | state $self; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 91 | ▶ | return $self if (ref $self eq 'PLS::Parser::Index'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 7 | my %args = @args; | |||||||||||||||||||||||||||||||||||||||||
| 41 | $self = bless { | ||||||||||||||||||||||||||||||||||||||||||
| 42 | workspace_folders => $args{workspace_folders}, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | subs => {}, | |||||||||||||||||||||||||||||||||||||||||
| 44 | packages => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | subs_by_package => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | files => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ignored_files => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ignore_files_mtimes => {} | ||||||||||||||||||||||||||||||||||||||||||
| 49 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } ## end sub new | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub workspace_folders | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 41 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
workspace_folders: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 41 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 41 | return $self->{workspace_folders}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | sub subs | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 28 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 28 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 28 | return $self->{subs}; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | sub packages | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
packages: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | return $self->{packages}; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub subs_by_package | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 28 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subs_by_package: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 28 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 28 | return $self->{subs_by_package}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | sub files | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 60 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 60 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 60 | return $self->{files}; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | sub _index_file | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_index_file: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my ($uri, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $text = PLS::Parser::Document->text_from_uri($uri) if (ref $text ne 'SCALAR'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $line_offsets = PLS::Parser::Index->get_line_offsets($text); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $packages = PLS::Parser::Index->get_packages($text, $uri, $line_offsets); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $subroutines = PLS::Parser::Index->get_subroutines($text, $uri, $line_offsets); | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return $packages, $subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } ## end sub _index_file | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | sub index_files | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_files: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my ($self, @uris) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | state $function; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 5 | ▶ | if (ref $function ne 'IO::Async::Function') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 5 | $function = IO::Async::Function->new(code => \&_index_file); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | IO::Async::Loop->new->add($function); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 5 | my $get_files_future; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | ▶ | if (scalar @uris) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $get_files_future = Future->done(\@uris); | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | else | ||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | $get_files_future = $self->get_all_perl_files_async(); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | return $get_files_future->then( | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | my ($uris) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | my @futures; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | my %open_files = map { $_ => 1 } PLS::Parser::Document->open_files(); | |||||||||||||||||||||||||||||||||||||||||
| 131 | 4 | require PLS::Parser::Document; | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | foreach my $uri (@{$uris}) | |||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | # If the file is open, pass the current text to the function, since the other | ||||||||||||||||||||||||||||||||||||||||||
| 136 | # process will not have the most up-to-date document text. | ||||||||||||||||||||||||||||||||||||||||||
| 137 | # If the file is not open, allow the function to open the file and get the text. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | my $version = PLS::Parser::Document::uri_version($uri); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 4 | ▶ | my $text = length $version ? PLS::Parser::Document->text_from_uri($uri) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | push @futures, $function->call(args => [$uri, $text])->then( | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 4 | my ($packages, $subs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | my $current_version = PLS::Parser::Document::uri_version($uri); | |||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | ▶ | return if (length $version and length $current_version and $current_version < $version); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
length $version and length $current_version and $current_version < $version
length $version and length $current_version
MC/DC0%0/3
length $version and length $current_version and $current_version < $version
length $version
length $current_version
$current_version < $version
Truth table25%1/4
A and B and C
A= length $versionB= length $current_versionC= $current_version < $version
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my $file = URI->new($uri)->file; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ▶ | return if $self->is_ignored($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | $file = path($file)->realpath if (-l $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | ▶ | return if $self->is_ignored($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | $self->cleanup_file($file); | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | foreach my $ref (keys %{$packages}) | |||||||||||||||||||||||||||||||||||||||||
| 157 | { | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | push @{$self->packages->{$ref}}, @{$packages->{$ref}}; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | push @{$self->files->{$file}{packages}}, $ref; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 4 | foreach my $ref (keys %{$subs}) | |||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 28 | push @{$self->subs->{$ref}}, @{$subs->{$ref}}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 28 | push @{$self->files->{$file}{subs}}, $ref; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 28 | foreach my $sub (@{$subs->{$ref}}) | |||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 28 | ▶ | push @{$self->subs_by_package->{$sub->{package}}}, $ref if (length $sub->{package}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | } ## end foreach my $ref (keys %{$subs...}) | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | return Future->done($file); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | } ## end foreach my $uri (@{$uris}) | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 4 | return Future->done(@futures); | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | )->retain(); | |||||||||||||||||||||||||||||||||||||||||
| 182 | } ## end sub index_files | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | sub get_all_perl_files_async | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_perl_files_async: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | my ($self, @folders) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | ▶ | @folders = @{$self->workspace_folders} unless (scalar @folders); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | ▶ | return Future->done([]) unless (scalar @folders); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | state $function; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | ▶ | if (ref $function ne 'IO::Async::Function') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | $function = IO::Async::Function->new(code => \&get_all_perl_files); | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | IO::Async::Loop->new->add($function); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } ## end if (ref $function ne 'IO::Async::Function'...) | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | return $function->call(args => [$self, @folders]); | |||||||||||||||||||||||||||||||||||||||||
| 201 | } ## end sub get_all_perl_files_async | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | sub deindex_workspace | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deindex_workspace: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | @{$self->workspace_folders} = grep { $_ ne $path } @{$self->workspace_folders}; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | foreach my $file (keys %{$self->files}) | |||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | next unless path($path)->subsumes($file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->cleanup_file($file); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } ## end foreach my $file (keys %{$self...}) | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } ## end sub deindex_workspace | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | sub index_workspace | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_workspace: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my ($self, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | push @{$self->workspace_folders}, $path; | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | $self->get_all_perl_files_async($path)->then( | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my ($workspace_uris) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | return $self->index_files(@{$workspace_uris}); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | )->then(sub { Future->wait_all(@_) })->retain(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } ## end sub index_workspace | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | sub cleanup_file | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cleanup_file: called CC=9 SCAR=35.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 4 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 4 | ▶ | $self->files->{$file}{subs} = [] if (ref $self->files->{$file}{subs} ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | ▶ | $self->files->{$file}{packages} = [] if (ref $self->files->{$file}{packages} ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | foreach my $ref (@{$self->files->{$file}{subs}}) | |||||||||||||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | @{$self->subs->{$ref}} = grep { $_->{uri} ne URI::file->new($file)->as_string() } @{$self->subs->{$ref}}; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | delete $self->subs->{$ref} unless (scalar @{$self->subs->{$ref}}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | foreach my $ref (@{$self->files->{$file}{packages}}) | |||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my @old_packages = @{$self->packages->{$ref}}; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | @{$self->packages->{$ref}} = (); | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | foreach my $package (@old_packages) | |||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ($package->{uri} eq URI::file->new($file)->as_string()) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | delete $self->subs_by_package->{$ref}; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | else | ||||||||||||||||||||||||||||||||||||||||||
| 261 | { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | push @{$self->packages->{$ref}}, $package; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | } ## end foreach my $package (@old_packages...) | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | delete $self->packages->{$ref} unless (scalar @{$self->packages->{$ref}}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | } ## end foreach my $ref (@{$self->files...}) | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | delete $self->files->{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } ## end sub cleanup_file | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub find_package_subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_package_subroutine: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($self, $package, $subroutine) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $locations = $self->packages->{$package}; | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if (ref $locations ne 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | require PLS::Parser::Document; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $external = PLS::Parser::Document->find_external_subroutine($package, $subroutine); | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | return [$external] if (ref $external eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||
| 286 | } ## end if (ref $locations ne ...) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my @subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | foreach my $file (@{$locations}) | |||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | push @subroutines, @{$self->find_subroutine($subroutine, $file->{uri})}; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return \@subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } ## end sub find_package_subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | sub find_subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_subroutine: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ($self, $subroutine, @uris) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $found = $self->subs->{$subroutine}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | return [] unless (ref $found eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $found = Storable::dclone($found); | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my %uris = map { $_ => 1 } @uris; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | @{$found} = grep { $uris{$_->{uri}} } @{$found} if (scalar @uris); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $found; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } ## end sub find_subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | sub find_package | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_package: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my ($self, $package) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $found = $self->packages->{$package}; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if (ref $found ne 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | require PLS::Parser::Document; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $external = PLS::Parser::Document->find_external_package($package); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | return [$external] if (ref $external eq 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||
| 324 | } ## end if (ref $found ne 'ARRAY'...) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return Storable::dclone($found); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } ## end sub find_package | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | sub get_ignored_files | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ignored_files: called CC=8 SCAR=33.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 8 | foreach my $workspace_folder (@{$self->workspace_folders}) | |||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 8 | my $plsignore = File::Spec->catfile($workspace_folder, '.plsignore'); | |||||||||||||||||||||||||||||||||||||||||
| 336 | 8 | ▶ | next if (not -f $plsignore or not -r $plsignore); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-f $plsignore and -r $plsignore
MC/DC0%0/2
-f $plsignore and -r $plsignore
-f $plsignore
-r $plsignore
Truth table33%1/3
A and B
A= -f $plsignoreB= -r $plsignore
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $mtime = stat($plsignore)->mtime; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | next if (length $self->{ignore_files_mtimes}{$plsignore} and $self->{ignore_file_mtimes}{$plsignore} >= $mtime); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $self->{"ignore_files_mtimes"}{$plsignore} and $self->{"ignore_file_mtimes"}{$plsignore} >= $mtime
MC/DC0%0/2
length $self->{"ignore_files_mtimes"}{$plsignore} and $self->{"ignore_file_mtimes"}{$plsignore} >= $mtime
length $self->{"ignore_files_mtimes"}{$plsignore}
$self->{"ignore_file_mtimes"}{$plsignore} >= $mtime
Truth table0%0/3
A and B
A= length $self->{"ignore_files_mtimes"}{$plsignore}B= $self->{"ignore_file_mtimes"}{$plsignore} >= $mtime
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | open my $fh, '<', $plsignore or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $self->{ignored_files}{$plsignore} = []; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->{ignore_file_mtimes}{$plsignore} = $mtime; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | while (my $line = <$fh>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | { | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | push @{$self->{ignored_files}{$plsignore}}, glob File::Spec->catfile($workspace_folder, $line); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | @{$self->{ignored_files}{$plsignore}} = map { path($_)->realpath } @{$self->{ignored_files}{$plsignore}}; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } ## end foreach my $workspace_folder... | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return [map { @{$self->{ignored_files}{$_}} } keys %{$self->{ignored_files}}]; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } ## end sub get_ignored_files | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | sub get_all_packages | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_packages: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | return [] if (ref $self->packages ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return [keys %{$self->packages}]; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } ## end sub get_all_packages | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | sub get_all_fully_qualified_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_fully_qualified_subroutines: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | return [] if (ref $self->subs_by_package ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my @subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | foreach my $package (keys %{$self->subs_by_package}) | |||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | foreach my $subroutine (@{$self->subs_by_package->{$package}}) | |||||||||||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | push @subroutines, "${package}::${subroutine}"; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | } ## end foreach my $package (keys %...) | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | return \@subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 383 | } ## end sub get_all_fully_qualified_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | sub is_ignored | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_ignored: called CC=4 SCAR=22.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 8 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 8 | my @ignore_files = @{$self->get_ignored_files()}; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 8 | ▶ | return unless (scalar @ignore_files); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $real_path = path($file)->realpath; | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | return 1 if any { $_ eq $real_path } @ignore_files; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | return 1 if any { $_->subsumes($real_path) } @ignore_files; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } ## end sub is_ignored | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | sub get_all_perl_files | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_perl_files: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my ($self, @folders) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | @folders = @{$self->workspace_folders} unless (scalar @folders); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | return [] unless (scalar @folders); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my @perl_files; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | File::Find::find( | ||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | preprocess => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | return () if $self->is_ignored($File::Find::dir); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return grep { not $self->is_ignored($_) } @_; | |||||||||||||||||||||||||||||||||||||||||
| 414 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return unless $self->is_perl_file($File::Find::name); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my @pieces = File::Spec->splitdir($File::Find::name); | |||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | # exclude hidden files and files in hidden directories | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | return if any { /^\./ } @pieces; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | push @perl_files, $File::Find::name; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } ## end sub | ||||||||||||||||||||||||||||||||||||||||||
| 424 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | @folders | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return [map { URI::file->new($_)->as_string } @perl_files]; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } ## end sub get_all_perl_files | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | sub is_perl_file | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_perl_file: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my ($class, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | return if -l $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | return if any { /^\.pls-tmp/ } grep { length } File::Spec->splitdir($file); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | return if $file =~ /\.t$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | return 1 if $file =~ /\.p[lm]$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | open my $fh, '<', $file or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $first_line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | return 1 if (length $first_line and $first_line =~ /^\s*#!.*perl$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $first_line and $first_line =~ /^\s*#!.*perl$/
MC/DC0%0/2
length $first_line and $first_line =~ /^\s*#!.*perl$/
length $first_line
$first_line =~ /^\s*#!.*perl$/
Truth table0%0/3
A and B
A= length $first_lineB= $first_line =~ /^\s*#!.*perl$/
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } ## end sub is_perl_file | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | sub log | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my (undef, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $time = Time::Piece->new; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $time = $time->ymd . ' ' . $time->hms; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | print {\*STDERR} "[$time] $message\n"; | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } ## end sub log | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | sub get_line_offsets | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_line_offsets: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my ($class, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my @line_offsets = (0); | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | while (${$text} =~ /\r?\n/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | push @line_offsets, pos ${$text}; | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | return \@line_offsets; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } ## end sub get_line_offsets | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | sub get_line_by_offset | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_line_by_offset: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my ($class, $line_offsets, $offset) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | foreach my $i (0 .. $#{$line_offsets}) | |||||||||||||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $current_offset = $line_offsets->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | my $next_offset = $i + 1 <= $#{$line_offsets} ? $line_offsets->[$i + 1] : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if ($current_offset <= $offset and (not defined $next_offset or $next_offset > $offset)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$current_offset <= $offset and !defined($next_offset) || $next_offset > $offset
not defined $next_offset or $next_offset > $offset
MC/DC0%0/3
$current_offset <= $offset and !defined($next_offset) || $next_offset > $offset
$current_offset <= $offset
not defined $next_offset
$next_offset > $offset
Truth table0%0/4
A and not(B) or C
A= $current_offset <= $offsetB= not defined $next_offsetC= $next_offset > $offset
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | { | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | return $i; | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } ## end foreach my $i (0 .. $#{$line_offsets...}) | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return $#{$line_offsets}; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } ## end sub get_line_by_offset | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | sub get_packages | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_packages: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my ($class, $text, $uri, $line_offsets) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | state $rx = qr/((?&PerlPackageDeclaration))$PPR::GRAMMAR/x; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my %packages; | |||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $file = URI->new($uri)->file; | |||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $file = path($file)->realpath if (-l $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $uri = URI::file->new($file)->as_string(); | |||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | while (${$text} =~ /$rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | { | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $end = pos ${$text}; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my $start = $end - length $name; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $start_line = $class->get_line_by_offset($line_offsets, $start); | |||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $start -= $line_offsets->[$start_line]; | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | my $end_line = $class->get_line_by_offset($line_offsets, $end); | |||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $end -= $line_offsets->[$end_line]; | |||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ($name) = $name =~ /package\s*(\S+)/; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $name =~ s/;$//; | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | push @{$packages{$name}}, | |||||||||||||||||||||||||||||||||||||||||
| 517 | { | ||||||||||||||||||||||||||||||||||||||||||
| 518 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||||||
| 519 | range => { | ||||||||||||||||||||||||||||||||||||||||||
| 520 | start => { | ||||||||||||||||||||||||||||||||||||||||||
| 521 | line => $start_line, | ||||||||||||||||||||||||||||||||||||||||||
| 522 | character => $start | ||||||||||||||||||||||||||||||||||||||||||
| 523 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 524 | end => { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | line => $end_line, | ||||||||||||||||||||||||||||||||||||||||||
| 526 | character => $end | ||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 530 | } ## end while (${$text} =~ /$rx/g...) | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | return \%packages; | |||||||||||||||||||||||||||||||||||||||||
| 533 | } ## end sub get_packages | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | sub get_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_subroutines: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my ($class, $text, $uri, $line_offsets) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $file = URI->new($uri)->file; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | $file = path($file)->realpath if (-l $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $uri = URI::file->new($file)->as_string(); | |||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | # Stolen mostly from PPR definition for PerlSubroutineDeclaration | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | state $sub_rx = qr{ | |||||||||||||||||||||||||||||||||||||||||
| 545 | (?<full> | ||||||||||||||||||||||||||||||||||||||||||
| 546 | (?<declaration>(?> | ||||||||||||||||||||||||||||||||||||||||||
| 547 | (?: (?> my | our | state ) \b (?>(?&PerlOWS)) )?+ | ||||||||||||||||||||||||||||||||||||||||||
| 548 | sub \b (?>(?&PerlOWS)) | ||||||||||||||||||||||||||||||||||||||||||
| 549 | (?<name>(?>(?&PerlOldQualifiedIdentifier))) (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 550 | | | ||||||||||||||||||||||||||||||||||||||||||
| 551 | (?<name>AUTOLOAD) (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 552 | | | ||||||||||||||||||||||||||||||||||||||||||
| 553 | (?<name>DESTROY) (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 554 | )) | ||||||||||||||||||||||||||||||||||||||||||
| 555 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 556 | # Perl pre 5.028 | ||||||||||||||||||||||||||||||||||||||||||
| 557 | (?: | ||||||||||||||||||||||||||||||||||||||||||
| 558 | (?> | ||||||||||||||||||||||||||||||||||||||||||
| 559 | (?<params>(?<label>(?&PerlParenthesesList))) # Parameter list | ||||||||||||||||||||||||||||||||||||||||||
| 560 | | | ||||||||||||||||||||||||||||||||||||||||||
| 561 | \( [^)]*+ \) # Prototype ( | ||||||||||||||||||||||||||||||||||||||||||
| 562 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 563 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 564 | )?+ | ||||||||||||||||||||||||||||||||||||||||||
| 565 | (?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+ | ||||||||||||||||||||||||||||||||||||||||||
| 566 | | | ||||||||||||||||||||||||||||||||||||||||||
| 567 | # Perl post 5.028 | ||||||||||||||||||||||||||||||||||||||||||
| 568 | (?: (?>(?&PerlAttributes)) (?&PerlOWS) )?+ | ||||||||||||||||||||||||||||||||||||||||||
| 569 | (?<params>(?<label>(?: (?>(?&PerlParenthesesList)) (?&PerlOWS) )?+)) # Parameter list | ||||||||||||||||||||||||||||||||||||||||||
| 570 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 571 | (?> ; | \{ | ||||||||||||||||||||||||||||||||||||||||||
| 572 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 573 | (?<label>(?<params>(?&PerlVariableDeclaration))(?&PerlOWS)=(?&PerlOWS)\@_;?)? | ||||||||||||||||||||||||||||||||||||||||||
| 574 | (?&PerlOWS) | ||||||||||||||||||||||||||||||||||||||||||
| 575 | (?>(?&PerlStatementSequence)) | ||||||||||||||||||||||||||||||||||||||||||
| 576 | \} ) | ||||||||||||||||||||||||||||||||||||||||||
| 577 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 578 | $PPR::GRAMMAR}x; | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | state $var_rx = qr/((?&PerlVariable)|undef)$PPR::GRAMMAR/; | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | state $package_rx = qr/((?&PerlPackageDeclaration))$PPR::GRAMMAR/; | |||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my %subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | while (${$text} =~ /$sub_rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | { | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $end = pos ${$text}; | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $start = $end - length $+{full}; | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $end = $start + length $+{declaration}; | |||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $start_line = $class->get_line_by_offset($line_offsets, $start); | |||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $start -= $line_offsets->[$start_line]; | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $end_line = $class->get_line_by_offset($line_offsets, $end); | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $end -= $line_offsets->[$end_line]; | |||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my $signature = $+{label}; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my @parameters; | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if (length $+{params}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | { | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $parameters = $+{params}; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | while ($parameters =~ /$var_rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | { | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | push @parameters, {label => $1}; | |||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | } ## end if (length $+{params}) | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $name = $+{name}; | |||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | # Look for package declaration anywhere from the start of the document | ||||||||||||||||||||||||||||||||||||||||||
| 611 | # to the subroutine declaration. | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $package; | |||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | if (substr(${$text}, 0, pos ${$text}) =~ /$package_rx/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | { | ||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ($package) = $1 =~ /^package\s+(.+)\s*;\s*$/; | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | push @{$subroutines{$name}}, | |||||||||||||||||||||||||||||||||||||||||
| 620 | { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||||||
| 622 | range => { | ||||||||||||||||||||||||||||||||||||||||||
| 623 | start => { | ||||||||||||||||||||||||||||||||||||||||||
| 624 | line => $start_line, | ||||||||||||||||||||||||||||||||||||||||||
| 625 | character => $start | ||||||||||||||||||||||||||||||||||||||||||
| 626 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 627 | end => { | ||||||||||||||||||||||||||||||||||||||||||
| 628 | line => $end_line, | ||||||||||||||||||||||||||||||||||||||||||
| 629 | character => $end | ||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||
| 631 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 632 | signature => {label => $signature, parameters => \@parameters}, | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 'package' => $package, | ||||||||||||||||||||||||||||||||||||||||||
| 634 | kind => 3 | ||||||||||||||||||||||||||||||||||||||||||
| 635 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 636 | } ## end while (${$text} =~ /$sub_rx/g...) | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | state $block_rx = qr/use\h+constant(?&PerlOWS)((?&PerlBlock))$PPR::GRAMMAR/; | |||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | state $bareword_rx = qr/((?&PerlBareword))(?&PerlOWS)(?&PerlComma)$PPR::GRAMMAR/; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | state $one_constant_rx = qr/use\h+constant\h+((?&PerlBareword))(?&PerlOWS)(?&PerlComma)$PPR::GRAMMAR/; | |||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | while (${$text} =~ /$block_rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | { | ||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | my $block = $1; | |||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $block_end = $+[1]; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $block_start = $-[1]; | |||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | # Look for package declaration anywhere from the start of the document | ||||||||||||||||||||||||||||||||||||||||||
| 649 | # to the constant declaration | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $package; | |||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if (substr(${$text}, 0, pos ${$text}) =~ /$package_rx/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ($package) = $1 =~ /^package\s+(.+)\s*;\s*$/; | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | while ($block =~ /$bareword_rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $bareword = $1; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $bareword_end = $+[1]; | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $bareword_start = $-[1]; | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $bareword_start += $block_start; | |||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $bareword_end += $block_start; | |||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my $start_line = $class->get_line_by_offset($line_offsets, $bareword_start); | |||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $bareword_start -= $line_offsets->[$start_line]; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $end_line = $class->get_line_by_offset($line_offsets, $bareword_end); | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $bareword_end -= $line_offsets->[$end_line]; | |||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | push @{$subroutines{$bareword}}, { | |||||||||||||||||||||||||||||||||||||||||
| 672 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||||||
| 673 | range => { | ||||||||||||||||||||||||||||||||||||||||||
| 674 | start => { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | line => $start_line, | ||||||||||||||||||||||||||||||||||||||||||
| 676 | character => $bareword_start | ||||||||||||||||||||||||||||||||||||||||||
| 677 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 678 | end => { | ||||||||||||||||||||||||||||||||||||||||||
| 679 | line => $end_line, | ||||||||||||||||||||||||||||||||||||||||||
| 680 | character => $bareword_end | ||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 'package' => $package, | ||||||||||||||||||||||||||||||||||||||||||
| 684 | kind => 21 # constant kind | ||||||||||||||||||||||||||||||||||||||||||
| 685 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 686 | } ## end while ($block =~ /$bareword_rx/g...) | ||||||||||||||||||||||||||||||||||||||||||
| 687 | } ## end while (${$text} =~ /$block_rx/g...) | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | while (${$text} =~ /$one_constant_rx/g) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | { | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $bareword = $1; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $end = $+[1]; | |||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my $start = $-[1]; | |||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | my $start_line = $class->get_line_by_offset($line_offsets, $start); | |||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $start -= $line_offsets->[$start_line]; | |||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | my $end_line = $class->get_line_by_offset($line_offsets, $end); | |||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $end -= $line_offsets->[$end_line]; | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | # Look for package declaration anywhere from the start of the document | ||||||||||||||||||||||||||||||||||||||||||
| 701 | # to the constant declaration | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | my $package; | |||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | if (substr(${$text}, 0, pos ${$text}) =~ /$package_rx/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ($package) = $1 =~ /^package\s+(.+)\s*;\s*$/; | |||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | push @{$subroutines{$bareword}}, { | |||||||||||||||||||||||||||||||||||||||||
| 710 | uri => $uri, | ||||||||||||||||||||||||||||||||||||||||||
| 711 | range => { | ||||||||||||||||||||||||||||||||||||||||||
| 712 | start => { | ||||||||||||||||||||||||||||||||||||||||||
| 713 | line => $start_line, | ||||||||||||||||||||||||||||||||||||||||||
| 714 | character => $start | ||||||||||||||||||||||||||||||||||||||||||
| 715 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 716 | end => { | ||||||||||||||||||||||||||||||||||||||||||
| 717 | line => $end_line, | ||||||||||||||||||||||||||||||||||||||||||
| 718 | character => $end | ||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 720 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 'package' => $package, | ||||||||||||||||||||||||||||||||||||||||||
| 722 | kind => 21 # constant kind | ||||||||||||||||||||||||||||||||||||||||||
| 723 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 724 | } ## end while (${$text} =~ /$one_constant_rx/g...) | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | return \%subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 727 | } ## end sub get_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||