| 1 | # | ||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2021-2023 Christian Jaeger, copying@christianjaeger.ch | ||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||||||||||||||||||||||||||||||||||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||||||||||||||||||||||||||||||||||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||||||||||||||||||||||||||||||||||
| 7 | # bundled with this file. | ||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | FunctionalPerl::Indexing -- retrieve information about the code base | ||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | use FunctionalPerl::Indexing qw( | ||||||||||||||||||||||||||||||||||
| 17 | identifierInfos_by_name Subroutine Package); | ||||||||||||||||||||||||||||||||||
| 18 | use FP::Equal qw(is_equal); | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | my $functional_perl_base_dir = "."; | ||||||||||||||||||||||||||||||||||
| 21 | my $by_name = identifierInfos_by_name( | ||||||||||||||||||||||||||||||||||
| 22 | $functional_perl_base_dir, | ||||||||||||||||||||||||||||||||||
| 23 | # accept all of them: | ||||||||||||||||||||||||||||||||||
| 24 | sub ($info) { 1 }); | ||||||||||||||||||||||||||||||||||
| 25 | is_equal($by_name->{first}->[0], | ||||||||||||||||||||||||||||||||||
| 26 | Subroutine('first', 'lib/FP/Array/Mixin.pm', 153)); | ||||||||||||||||||||||||||||||||||
| 27 | is_equal($by_name->{"FP::List"}->[0], | ||||||||||||||||||||||||||||||||||
| 28 | Package('FP::List', 'lib/FP/List.pm', 127, '')); | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | =head1 NOTE | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | This is alpha software! Read the status section in the package README | ||||||||||||||||||||||||||||||||||
| 36 | or on the L<website|http://functional-perl.org/>. | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | =cut | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | package FunctionalPerl::Indexing; | ||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | use warnings FATAL => 'uninitialized'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | no warnings 'shadow'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | use Exporter "import"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 2 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||
| 50 | 2 | our @EXPORT_OK = qw(identifierInfos_by_name Subroutine Package); | |||||||||||||||||||||||||||||||||
| 51 | 2 | our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); | |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | use File::chdir; # qw($CWD) nope, can't request it explicitly. | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 54 | 2 | ▶ | use Chj::xopen qw(xopen_read); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | use Chj::IO::Command; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | use FP::Docstring; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | use FP::Predicates qw(is_defined $package_re); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | use FP::PureArray; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | use Chj::xopen qw(xopen_read); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 60 | 2 | ▶ | use FP::IOStream qw(xfile_lines); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | use FP::Lazy; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | use Digest::MD5 qw(md5_hex); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | use Chj::TEST ":all"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | # ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 2 | package FunctionalPerl::Indexing::IdentifierInfo { | |||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | use FP::Struct ["name", "file", "lineno"] => | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 70 | 2 | ("FP::Struct::Show", "FP::Struct::Equal"); | |||||||||||||||||||||||||||||||||
| 71 | 2 | _END_ | |||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | 2 | package FunctionalPerl::Indexing::Subroutine { | |||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | use FP::Struct [] => "FunctionalPerl::Indexing::IdentifierInfo"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 76 | 2 | _END_ | |||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||
| 78 | 2 | FunctionalPerl::Indexing::Subroutine::constructors->import; | |||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 2 | package FunctionalPerl::Indexing::Package { | |||||||||||||||||||||||||||||||||
| 81 | 2 | ▶ | use Chj::Packages qw(xrequire_package_by_path); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | use FP::Docstring; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | use FP::Struct ["is_newstyle"] => | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 85 | 2 | "FunctionalPerl::Indexing::IdentifierInfo"; | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 6 | ▶ | sub package_type ($self) { | ||||||||||||||||||||||||||||||||
|
Subroutine
package_type: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||
| 88 | 6 | __ 'Return "exporter" if it can export things via "use", or | |||||||||||||||||||||||||||||||||
| 89 | "class" otherwise. This loads the package to get access | ||||||||||||||||||||||||||||||||||
| 90 | to is variables at runtime!'; | ||||||||||||||||||||||||||||||||||
| 91 | 6 | ▶ | $self->{_package_type} //= do { | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_package_type"} //= do {
xrequire_package_by_path($self->file);
no strict 'refs';
my $stash = \%{$self->{"name"} . '::';};
my(%isa) = map({$_, 1;} @{$stash->{"ISA"} or [];});
if ($isa{"Exporter"}) {
"exporter";
}
elsif (exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}) {
"exporter";
}
elsif (exists $stash->{"import"}) {
"exporter";
}
else {
"class";
}
}
MC/DC0%0/2
$self->{"_package_type"} //= do {
xrequire_package_by_path($self->file);
no strict 'refs';
my $stash = \%{$self->{"name"} . '::';};
my(%isa) = map({$_, 1;} @{$stash->{"ISA"} or [];});
if ($isa{"Exporter"}) {
"exporter";
}
elsif (exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}) {
"exporter";
}
elsif (exists $stash->{"import"}) {
"exporter";
}
else {
"class";
}
}
$self->{"_package_type"}
do {
xrequire_package_by_path($self->file);
no strict 'refs';
my $stash = \%{$self->{"name"} . '::';};
my(%isa) = map({$_, 1;} @{$stash->{"ISA"} or [];});
if ($isa{"Exporter"}) {
"exporter";
}
elsif (exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}) {
"exporter";
}
elsif (exists $stash->{"import"}) {
"exporter";
}
else {
"class";
}
}
Truth table33%1/3
A //= B
A= $self->{"_package_type"}B= do {
xrequire_package_by_path($self->file);
no strict 'refs';
my $stash = \%{$self->{"name"} . '::';};
my(%isa) = map({$_, 1;} @{$stash->{"ISA"} or [];});
if ($isa{"Exporter"}) {
"exporter";
}
elsif (exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}) {
"exporter";
}
elsif (exists $stash->{"import"}) {
"exporter";
}
else {
"class";
}
}
| |||||||||||||||||||||||||||||||||||
| 92 | 6 | xrequire_package_by_path $self->file; | |||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 94 | 6 | my $stash = \%{ $self->{name} . "::" }; | |||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | # (`|| []` might not be needed, as I didn't get an error | ||||||||||||||||||||||||||||||||||
| 97 | # in my tests, but oddly it is needed for EXPORT.) | ||||||||||||||||||||||||||||||||||
| 98 | 6 | ▶ | my %isa = map { $_ => 1 } @{ $stash->{ISA} || [] }; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$stash->{'ISA'} || []
MC/DC100%1/1
$stash->{'ISA'} || []
$stash->{'ISA'}
Truth table100%2/2
A
A= $stash->{'ISA'}
| |||||||||||||||||||||||||||||||||||
| 99 | 6 | ▶ | if ($isa{Exporter}) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 100 | 1 | "exporter" | |||||||||||||||||||||||||||||||||
| 101 | ▶ | } elsif (exists $stash->{EXPORT} | |||||||||||||||||||||||||||||||||
|
Condition66%4/6
exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}
exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"}
MC/DC33%1/3
exists $stash->{"EXPORT"} or exists $stash->{"EXPORT_OK"} or exists $stash->{"EXPORT_TAGS"}
exists $stash->{"EXPORT"}
exists $stash->{"EXPORT_OK"}
exists $stash->{"EXPORT_TAGS"}
Truth table50%2/4
A or B or C
A= exists $stash->{"EXPORT"}B= exists $stash->{"EXPORT_OK"}C= exists $stash->{"EXPORT_TAGS"}
| |||||||||||||||||||||||||||||||||||
| 102 | or exists $stash->{EXPORT_OK} | ||||||||||||||||||||||||||||||||||
| 103 | or exists $stash->{EXPORT_TAGS}) | ||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||
| 105 | 1 | "exporter" | |||||||||||||||||||||||||||||||||
| 106 | } elsif (exists $stash->{import}) { | ||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | # warn "non Exporter kind of exporter"; | ||||||||||||||||||||||||||||||||||
| 109 | 1 | "exporter" | |||||||||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||||||||
| 111 | 3 | "class" | |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||
| 115 | 2 | _END_ | |||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||
| 117 | 2 | FunctionalPerl::Indexing::Package::constructors->import; | |||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | TEST { Package("FP::List", "lib/FP/List.pm", 123)->package_type } 'exporter'; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 120 | 1 | ▶ | TEST { Package("FP::List::List", "lib/FP/List.pm", 123)->package_type } 'class'; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | TEST { Package("FP::List::Pair", "lib/FP/List.pm", 123)->package_type } 'class'; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | TEST { Package("Chj::TEST", "lib/Chj/TEST.pm", 123)->package_type } 'exporter'; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | TEST { Package("PXML::Tags", "lib/PXML/Tags.pm", 123)->package_type } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 124 | 2 | 'exporter'; | |||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | TEST { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 126 | 1 | Package("FP::Abstract::Sequence", "lib/FP/Abstract/Sequence.pm", 123) | |||||||||||||||||||||||||||||||||
| 127 | ->package_type | ||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||
| 129 | 2 | 'class'; # might change? | |||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | 2 | my $var_re = qr/[a-zA-Z_]\w*/; | |||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | 197 | ▶ | sub file_IdentifierInfos ($path) { | ||||||||||||||||||||||||||||||||
|
Subroutine
file_IdentifierInfos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | #my $lines = xfile_lines($path)->purearray; | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | # Not using xfile_lines makes user time go down from 0m1.096s to | ||||||||||||||||||||||||||||||||||
| 138 | # 0m0.336s. XX do something about it... | ||||||||||||||||||||||||||||||||||
| 139 | 197 | my $lines = do { | |||||||||||||||||||||||||||||||||
| 140 | 197 | my $in = xopen_read($path); | |||||||||||||||||||||||||||||||||
| 141 | 197 | my $lines = purearray $in->xreadline; | |||||||||||||||||||||||||||||||||
| 142 | 197 | $in->xclose; | |||||||||||||||||||||||||||||||||
| 143 | 197 | $lines | |||||||||||||||||||||||||||||||||
| 144 | }; | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | $lines->map_with_index( | ||||||||||||||||||||||||||||||||||
| 147 | 43119 | ▶ | sub ($i, $line) { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 148 | 43119 | my $lineno = $i + 1; | |||||||||||||||||||||||||||||||||
| 149 | 43119 | ▶ | if (my ($pre, $name) = $line =~ /^(.*?)\bsub ($var_re)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 150 | 1837 | ▶ | if ($pre =~ /["']/ or $pre =~ /\bq\b/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pre =~ /["']/ or $pre =~ /\bq\b/
MC/DC50%1/2
$pre =~ /["']/ or $pre =~ /\bq\b/
$pre =~ /["']/
$pre =~ /\bq\b/
Truth table66%2/3
A or B
A= $pre =~ /["']/B= $pre =~ /\bq\b/
| |||||||||||||||||||||||||||||||||||
| 151 | undef | ||||||||||||||||||||||||||||||||||
| 152 | 4 | } else { | |||||||||||||||||||||||||||||||||
| 153 | 1833 | Subroutine($name, $path, $lineno) | |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | } elsif (my ($name) = $line =~ /^\s*\*\s*($var_re)\s*=/) { | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | # The setting of a glob. *Assume* that it's for a code | ||||||||||||||||||||||||||||||||||
| 158 | # ref. XX improve? | ||||||||||||||||||||||||||||||||||
| 159 | 198 | Subroutine($name, $path, $lineno) | |||||||||||||||||||||||||||||||||
| 160 | } elsif (my ($name, $post) | ||||||||||||||||||||||||||||||||||
| 161 | = $line =~ /package\s+($package_re)\s*(;|\{)/) | ||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||
| 163 | 324 | Package($name, $path, $lineno, $post eq '{') | |||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||
| 165 | undef | ||||||||||||||||||||||||||||||||||
| 166 | 40760 | } | |||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||
| 168 | 197 | )->filter(\&is_defined) | |||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | sub files_IdentifierInfos_by_name ($files, $acceptableP) { | ||||||||||||||||||||||||||||||||
|
Subroutine
files_IdentifierInfos_by_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 172 | 1 | __ 'Sequence of file paths -> +{name => [IdentifierInfo...]}'; | |||||||||||||||||||||||||||||||||
| 173 | 1 | my %by_name; | |||||||||||||||||||||||||||||||||
| 174 | $files->map(\&file_IdentifierInfos)->for_each( | ||||||||||||||||||||||||||||||||||
| 175 | 197 | ▶ | sub ($infos) { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 176 | $infos->filter($acceptableP)->for_each( | ||||||||||||||||||||||||||||||||||
| 177 | 2355 | ▶ | sub ($info) { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 178 | 2355 | push @{ $by_name{ $info->name } }, $info; | |||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||
| 180 | 197 | ); | |||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||
| 182 | 1 | ); | |||||||||||||||||||||||||||||||||
| 183 | 1 | \%by_name | |||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | sub perlfiles() { | ||||||||||||||||||||||||||||||||
|
Subroutine
perlfiles: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 187 | 1 | my $manifest = xopen_read("MANIFEST")->xcontent; | |||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | # Remove the entries again which are added by the relase process; | ||||||||||||||||||||||||||||||||||
| 190 | # they have whitespace in the lines. | ||||||||||||||||||||||||||||||||||
| 191 | 1 | $manifest =~ s{(?:^|\n)\S+[ \t]+[^\n]+}{}sg; | |||||||||||||||||||||||||||||||||
| 192 | 1 | my $newsum = md5_hex($manifest); | |||||||||||||||||||||||||||||||||
| 193 | 1 | my $in = xopen_read(".perlfiles"); | |||||||||||||||||||||||||||||||||
| 194 | 1 | my $oldsum = $in->xreadline; | |||||||||||||||||||||||||||||||||
| 195 | 1 | chomp $oldsum; | |||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | if ($newsum ne $oldsum) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 197 | 0 | die ".perlfiles is outdated; please run, in the Git checkout, " | |||||||||||||||||||||||||||||||||
| 198 | . "with chj-scripts installed (you're meant to be the maintainer):\n" | ||||||||||||||||||||||||||||||||||
| 199 | . " meta/perlfiles \n "; | ||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | 1 | my @perlfiles = $in->xreadline; | |||||||||||||||||||||||||||||||||
| 202 | 1 | $in->xclose; | |||||||||||||||||||||||||||||||||
| 203 | 1 | chomp @perlfiles; | |||||||||||||||||||||||||||||||||
| 204 | 1 | purearray @perlfiles | |||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | sub identifierInfos_by_name ($functional_perl_base_dir, $acceptableP) { | ||||||||||||||||||||||||||||||||
|
Subroutine
identifierInfos_by_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 208 | 1 | __ '(Path to functional-perl base directory, $acceptableP) -> | |||||||||||||||||||||||||||||||||
| 209 | +{name => [IdentifierInfo...]}; $acceptableP is a predicate | ||||||||||||||||||||||||||||||||||
| 210 | returning true for those instances you want.'; | ||||||||||||||||||||||||||||||||||
| 211 | 1 | local $CWD = $functional_perl_base_dir; | |||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||
| 213 | # Ignore files that can't be used for imports and aren't examples, OK? | ||||||||||||||||||||||||||||||||||
| 214 | my $files | ||||||||||||||||||||||||||||||||||
| 215 | 1 | ▶ | = perlfiles->filter(sub ($v) { $v =~ /\.pm$/ or $v =~ /^examples\// }); | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 216 | 1 | files_IdentifierInfos_by_name $files, $acceptableP | |||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||
| 219 | # for tests only: | ||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | my $by_name = lazy { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 221 | 2355 | ▶ | identifierInfos_by_name ".", sub($v) {1} | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 222 | 1 | }; | |||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | 5 | ▶ | sub scrubline { | ||||||||||||||||||||||||||||||||
|
Subroutine
scrubline: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 225 | 5 | my ($ary) = @_; | |||||||||||||||||||||||||||||||||
| 226 | 5 | [map { $_->lineno_set(123) } @$ary] | |||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 5 | ▶ | sub t { | ||||||||||||||||||||||||||||||||
|
Subroutine
t: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 230 | 5 | scrubline force($by_name)->{ $_[0] } | |||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | 1 | ▶ | TEST { t "car" } [ | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 234 | 2 | Subroutine('car', 'lib/FP/List.pm', 123), | |||||||||||||||||||||||||||||||||
| 235 | Subroutine('car', 'lib/FP/List.pm', 123) | ||||||||||||||||||||||||||||||||||
| 236 | ]; | ||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | TEST { t "first" } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 238 | [ | ||||||||||||||||||||||||||||||||||
| 239 | 2 | Subroutine('first', 'lib/FP/Array/Mixin.pm', 123), | |||||||||||||||||||||||||||||||||
| 240 | Subroutine('first', 'lib/FP/List.pm', 123), | ||||||||||||||||||||||||||||||||||
| 241 | Subroutine('first', 'lib/FP/List.pm', 123), | ||||||||||||||||||||||||||||||||||
| 242 | Subroutine('first', 'lib/FP/List.pm', 123), | ||||||||||||||||||||||||||||||||||
| 243 | Subroutine('first', 'lib/FP/List.pm', 123) | ||||||||||||||||||||||||||||||||||
| 244 | ]; | ||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | TEST { t "FP::List" } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 246 | 2 | [Package('FP::List', 'lib/FP/List.pm', 123, '')]; | |||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | TEST { t "FP::List::Pair" } [ | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 248 | 2 | Package('FP::List::Pair', 'lib/FP/List.pm', 123, 1), | |||||||||||||||||||||||||||||||||
| 249 | Package('FP::List::Pair', 'lib/FP/List.pm', 123, 1) | ||||||||||||||||||||||||||||||||||
| 250 | ]; | ||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||
| 252 | # ------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||
| 254 | # If you wanted to get methods from interfaces: | ||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||
| 256 | # (Which would only be worthwhile for generating the HTML crosslinking | ||||||||||||||||||||||||||||||||||
| 257 | # thing, since for just the names, all methods will exist as sub or * | ||||||||||||||||||||||||||||||||||
| 258 | # definitions and be picked up anyway.) | ||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | # sub all_abstract_files() { | ||||||||||||||||||||||||||||||||||
| 261 | # glob "lib/FP/Abstract/*pm" | ||||||||||||||||||||||||||||||||||
| 262 | # } | ||||||||||||||||||||||||||||||||||
| 263 | # no, better access from the index!: | ||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | TEST { t "FP_Interface__method_names" } [ | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 266 | 2 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Compare.pm', 123), | |||||||||||||||||||||||||||||||||
| 267 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Equal.pm', 123), | ||||||||||||||||||||||||||||||||||
| 268 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Id.pm', 123), | ||||||||||||||||||||||||||||||||||
| 269 | Subroutine( | ||||||||||||||||||||||||||||||||||
| 270 | 'FP_Interface__method_names', 'lib/FP/Abstract/Interface.pm', 123 | ||||||||||||||||||||||||||||||||||
| 271 | ), | ||||||||||||||||||||||||||||||||||
| 272 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Map.pm', 123), | ||||||||||||||||||||||||||||||||||
| 273 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Pure.pm', 123), | ||||||||||||||||||||||||||||||||||
| 274 | Subroutine( | ||||||||||||||||||||||||||||||||||
| 275 | 'FP_Interface__method_names', 'lib/FP/Abstract/Sequence.pm', 123 | ||||||||||||||||||||||||||||||||||
| 276 | ), | ||||||||||||||||||||||||||||||||||
| 277 | Subroutine('FP_Interface__method_names', 'lib/FP/Abstract/Show.pm', 123), | ||||||||||||||||||||||||||||||||||
| 278 | Subroutine('FP_Interface__method_names', 'lib/FP/Interface.pm', 123), | ||||||||||||||||||||||||||||||||||
| 279 | Subroutine('FP_Interface__method_names', 'lib/FP/Interface.pm', 123) | ||||||||||||||||||||||||||||||||||
| 280 | ]; | ||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||
| 282 | 2 | 1 | |||||||||||||||||||||||||||||||||