« blib/lib/YATT/Lite/WebMVC0/Partial/Session3.pm
↑ Summary
blib/lib/YATT/Lite/WebMVC0/SiteApp/CGI.pm »
| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package YATT::Lite::Inspector; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use File::AddInc; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use MOP4Import::Base::CLI_JSON -as_base | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | , [fields => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | qw/_SITE _app_root _file_line_cache/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | [dir => doc => "starting directory to search app.psgi upward"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | [search_boundary => doc => "never search app.psgi above this directory (the language server sets it to the workspace root)"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | [emit_absolute_path => doc => "emit absolute path instead of \$app_root-relative"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | [site_class => doc => "class name for SiteApp (to load app.psgi)", default => "YATT::Lite::WebMVC0::SiteApp"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | [ignore_symlink => doc => "ignore symlinked templates"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | [detail => doc => "show argument details"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | [line_base => default => 1], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | [debug_changes_dir => doc => "(LSP debugging only)" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | , default => "var/debug_yatt_ls"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # qw/debug/, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | ▶ | use MOP4Import::Util qw/lexpand symtab terse_dump globref isa_array/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | use MOP4Import::Types | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 12 | ▶ | Zipper => [[fields => qw/array index path defs/]] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | , SymbolInfo => [[fields => qw/kind name filename range refpos/] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | , [subtypes => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | , VarInfo => [[fields => qw/type detail/]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | , EntityInfo => [[fields => qw/name entns file line/]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | , LintResult => [[fields => qw/type is_success | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | info | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | file diagnostics/]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 12 | ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 12 | ▶ | use parent qw/File::Spec/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 12 | ▶ | use URI::file; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 12 | ▶ | use Text::Glob; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 12 | ▶ | use Plack::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 12 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12 | ▶ | use File::stat; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 12 | ▶ | use File::Path qw(make_path); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12 | ▶ | use File::Slurp qw(write_file); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 12 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | ▶ | use YATT::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | ▶ | use YATT::Lite::Factory; sub Factory () {'YATT::Lite::Factory'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | ▶ | use YATT::Lite::LRXML; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | ▶ | use YATT::Lite::Core qw/Part Widget Template/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | ▶ | use YATT::Lite::CGen::Perl; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 12 | ▶ | use YATT::Lite::VFS qw/Folder/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | use MOP4Import::Types | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 12 | ▶ | ArgSpec => [ | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | [fields => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | YATT::Lite::VarTypes->list_field_names, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 'is_required', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 12 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | use YATT::Lite::LRXML::AltTree qw/column_of_source_pos AltNode/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | ▶ | use YATT::Lite::Walker qw/walk walk_vfs_folders/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | use YATT::Lite::LanguageServer::Protocol | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | ▶ | qw/Position Range MarkupContent | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | Location | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | Diagnostic | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | TextDocumentContentChangeEvent | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | DocumentSymbol | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | CompletionItem | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | / | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | , qr/^DiagnosticSeverity__/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | , qr/^SymbolKind__/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | , qr/^InsertTextFormat__/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 12 | ; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 17 | ▶ | sub after_configure_default { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_configure_default: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 17 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 17 | $self->SUPER::after_configure_default; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 17 | $self->{_SITE} = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # Site->load caches per factory script, so multiple Inspectors can | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # coexist in one process. Bare template dirs (no app.psgi) get a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # default site instead of dying. GH-269 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 17 | my $class = Plack::Util::load_class($self->{site_class}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $class->load_or_default(dir => $self->{dir} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | , class => $self->{site_class} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | , (defined $self->{search_boundary} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 17 | ▶ | ? (stop_at => $self->{search_boundary}) : ())); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 17 | $self->{_app_root} = $self->{_SITE}->cget('app_root'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 17 | $self->debug_log("Initialized"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub cmd_ctags_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_ctags_symbols: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ($dir) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $cwdOrFileList = $self->list_target_dirs($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | walk( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | widget => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my Part $widget = $args->{part}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my Template $tmpl = $widget->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $path = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->emit_ctags($args->{kind}, $args->{name}, $path, $widget->{startln}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | item => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $path = $args->{_tree}->cget('path'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my ($kind, $name) = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if (-l $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | (symlink => readlink($path)) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | (file => $self->clean_path($path)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->emit_ctags($kind => $name, $path, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 13 | ▶ | sub clean_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_path: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 13 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 13 | ▶ | if (not $self->{emit_absolute_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 13 | $path =~ s,^$self->{_app_root}/*,,; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 13 | $path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # Same format with "ctags -x --_xformat=%{input}:%n:1:%K!%N" (I hope). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub emit_ctags { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_ctags: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | (my MY $self, my ($kind, $name, $fileName, $lineNo, $colNo)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # XXX: symbolKind mapping. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | printf "%s:%d:%d:%s!%s\n", $self->clean_path($fileName) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$colNo // 1
MC/DC0%0/1
$colNo // 1
$colNo
Truth table0%0/2
A
A= $colNo
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | , $lineNo, $colNo // 1, $kind, $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub load_string_into_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_string_into_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | (my MY $self, my ($fileName, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $core->get_parser->load_string_into($tmpl, $text, all => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | $result //= +{}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $self->yatterror2lintresult($_, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub apply_changes { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_changes: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | (my MY $self, my ($fileName, @changes)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my Template $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my $lines = [defined $tmpl->{string} && $tmpl->{string} ne "" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | ? (split /\n/, $tmpl->{string}, -1) : ("")]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tmpl->{"string"} and $tmpl->{"string"} ne ""
MC/DC0%0/2
defined $tmpl->{"string"} and $tmpl->{"string"} ne ""
defined $tmpl->{"string"}
$tmpl->{"string"} ne ""
Truth table0%0/3
A and B
A= defined $tmpl->{"string"}B= $tmpl->{"string"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | foreach my TextDocumentContentChangeEvent $change (@changes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $lines = $self->apply_change_to_lines($lines, $change); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $tmpl->{mtime} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $changed = join("\n", @$lines); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ($self->debug_changes_dir_exists) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $destFn = $self->debug_changes_write_file($fileName, $changed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | print STDERR "# Wrote: $destFn\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $core->get_parser->load_string_into($tmpl, $changed, all => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $tmpl->{string} = $changed; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $result //= +{}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $self->yatterror2lintresult($_, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $result->{info}{from} = ["line: ", __LINE__]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if (not $result) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my LintResult $res = $self->lint($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | $result = $res unless $res->{is_success}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ($changed, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | sub head_as_json_array { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head_as_json_array: not called CC=4 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $limit = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($_[0] =~ /^-(\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $limit = $1; shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 12 | ▶ | use open qw(:std :locale); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | local @ARGV = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | while (<>) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | push @result, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | last if --$limit <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | \@result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub debug_changes_dir_exists { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_changes_dir_exists: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | defined $self->{dir} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | -e "$self->{dir}/DEBUG_YATT_LANGSERVER" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"dir"} and -e qq[$self->{"dir"}/DEBUG_YATT_LANGSERVER]
MC/DC0%0/2
defined $self->{"dir"} and -e qq[$self->{"dir"}/DEBUG_YATT_LANGSERVER]
defined $self->{"dir"}
-e qq[$self->{"dir"}/DEBUG_YATT_LANGSERVER]
Truth table0%0/3
A and B
A= defined $self->{"dir"}B= -e qq[$self->{"dir"}/DEBUG_YATT_LANGSERVER]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | -d "$self->{dir}/$self->{debug_changes_dir}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub debug_changes_write_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_changes_write_file: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | (my MY $self, my ($fileName, $changed)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $debugDir = "$self->{dir}/$self->{debug_changes_dir}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | substr($fileName, 0, length $self->{dir}) = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $destFn = "$debugDir/$fileName." . Time::HiRes::time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $destDir = File::Basename::dirname($destFn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | unless (-d $destDir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | make_path($destDir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | write_file($destFn, +{binmode => ':utf8'}, $changed); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Z-chtholly(pts/0)% ./Lite/Inspector.pm apply_change_to_lines '["fooooo","bar","baz"]' '{"text":"xx","range":{"start":{"line":0,"character":1},"end":{"line":0,"character":2}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # [["fxxoooo","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # Z-chtholly(pts/0)% ./Lite/Inspector.pm apply_change_to_lines '["fooooo","bar","baz"]' '{"text":"xx","range":{"start":{"line":0,"character":1},"end":{"line":0,"character":1}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # [["fxxooooo","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # Z-chtholly(pts/0)% ./Lite/Inspector.pm apply_change_to_lines '["fooooo","bar","baz"]' '{"text":"xx","range":{"start":{"line":0,"character":1},"end":{"line":0,"character":100}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # [["fxx","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # Z-chtholly(pts/0)% ./Lite/Inspector.pm apply_change_to_lines '["fooooo","bar","baz"]' '{"text":"xx","range":{"start":{"line":0,"character":1},"end":{"line":1,"character":1}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | # [["fxxar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub cmd_apply_all_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_apply_all_change_to_lines: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | (my MY $self, my $linesOrFileName, my $changeList) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my $lines = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if (ref $linesOrFileName) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $linesOrFileName | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | [split /\r?\n/, YATT::Lite::Util::read_file($linesOrFileName)] | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $result = $self->apply_all_change_to_lines($lines, $changeList); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | print $_, "\n" for @$result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub apply_all_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_all_change_to_lines: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | (my MY $self, my $lines, my $changeList) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | foreach my TextDocumentContentChangeEvent $change (@$changeList) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $lines = $self->apply_change_to_lines($lines, $change); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub apply_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_change_to_lines: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | (my MY $self, my $lines, my TextDocumentContentChangeEvent $change) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my Range $from = $change->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | unless ($from) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # Full document sync: the whole text replaces the document. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | my $text = $change->{text} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$change->{"text"} // ""
MC/DC0%0/1
$change->{"text"} // ""
$change->{"text"}
Truth table0%0/2
A
A= $change->{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | return [$text ne '' ? split(/\n/, $text, -1) : ('')]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my Position $start = $from->{start}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my Position $end = $from->{end}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my @pre = @{$lines}[0 .. $start->{line}-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my @post = @{$lines}[$end->{line}+1 .. $#$lines]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($start->{line} == $end->{line}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my @edited = $lines->[$start->{line}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | substr($edited[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | , $start->{character}, $end->{character} - $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | , $change->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | @edited = split /\n/, $edited[0], -1 if $edited[0] ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | Carp::croak "failed to apply changes: " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | . terse_dump([original => $lines->[$start->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | , start => $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | , len => $end->{character} - $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | , changed => $change->{text}]). ": $_"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | [@pre, @edited, @post]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my ($pre_edit, $post_edit); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $pre_edit = substr($lines->[$start->{line}], 0, $start->{character}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $post_edit = substr($lines->[$end->{line}], $end->{character}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Carp::croak "failed to apply multiline changes: " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | . terse_dump([pre => [original => $lines->[$start->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | , start => $start->{character}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | , post => [original => $lines->[$end->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | , end => $end->{character}] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | , changed => $change->{text}]). ": $_"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $edited = $pre_edit.$change->{text}.$post_edit; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | my @edited = $edited ne '' ? split(/\n/, $edited, -1) : $edited; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | [@pre, @edited, @post]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub append_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | (my MY $self, my ($fileName, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my Range $ending = $self->file_ending_range($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | $self->apply_changes($fileName, +{ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | range => $ending, rangeLength => 0, text => $text | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub file_ending_range { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_ending_range: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | (my MY $self, my ($fileNameOrTemplate)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my Template $tmpl = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if (ref $fileNameOrTemplate) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | unless ($fileNameOrTemplate->isa(Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | Carp::croak "Invalid argument type: ". ref($fileNameOrTemplate) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | $fileNameOrTemplate | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $self->find_template($fileNameOrTemplate); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my ($lineNo, $colNo) = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | my $lines = [defined $tmpl->{string} && $tmpl->{string} ne "" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | ? (split /\n/, $tmpl->{string}, -1) : ("")]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $tmpl->{"string"} and $tmpl->{"string"} ne ""
MC/DC0%0/2
defined $tmpl->{"string"} and $tmpl->{"string"} ne ""
defined $tmpl->{"string"}
$tmpl->{"string"} ne ""
Truth table0%0/3
A and B
A= defined $tmpl->{"string"}B= $tmpl->{"string"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $lastLine = $lines->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ($#$lines, length($lastLine)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my Position $start = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $start->{line} = $lineNo; $start->{character} = $colNo; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my Position $end = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $end->{line} = $lineNo; $end->{character} = $colNo; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my Range $range = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $range->{start} = $start; $range->{end} = $end; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 15 | ▶ | sub lint : method { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lint: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 15 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 15 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 15 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | my $mtime; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 15 | my $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 15 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 15 | ▶ | if (-r $fileName) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 15 | $mtime = stat($fileName)->mtime; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | $self->{_SITE}->cf_let([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | ▶ | error_handler => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | (my $type, my YATT::Lite::Error $err) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | $result->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | $self->yatterror2lintresult($err, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | die $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 15 | ▶ | ], sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 15 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | # $yatt->fconfigure_encoding(\*STDOUT, \*STDERR); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # get_trans is not ok. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 15 | $tmpl->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 15 | my $pkg = $core->find_product(perl => $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 5 | $result->{is_success} = JSON()->true; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 5 | $result->{info}{mtime} = [$mtime, $tmpl->{mtime}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 10 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 10 | ▶ | unless ($result) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 9 | my $backtrace; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 9 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table50%1/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 8 | ▶ | $self->yatterror2lintresult($_, $result //= +{}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table50%1/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 8 | $backtrace = $_->{backtrace}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $result->{info}{from} = ["line: ", __LINE__]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 9 | ▶ | $result->{info}{mtime} = [$mtime, $tmpl->{mtime}] if defined $mtime; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 9 | ▶ | $result->{info}{backtrace} = $self->backtrace2list($backtrace) if $backtrace; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 15 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 15 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 9 | ▶ | sub yatterror2lintresult { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
yatterror2lintresult: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 9 | (my MY $self, my YATT::Lite::Error $err, my LintResult $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 12 | ▶ | use YATT::Lite::Util::AllowRedundantSprintf; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 9 | $result->{info}{from} = 'yatterror2lintresult'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 9 | $result->{file} = $err->{tmpl_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 9 | $result->{diagnostics} = my Diagnostic $diag = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 9 | $diag->{severity} = DiagnosticSeverity__Error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 9 | ▶ | $diag->{message} = $err->{reason} // do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$err->{"reason"} // do {
my $str;
&try(sub {
$str = sprintf($err->{"format"}, @{$$err{"args"};});
}
, &catch(sub {
$str = terse_dump([$_, $err->{"format"}, @{$err->{"args"};}]);
}
));
$str
}
MC/DC0%0/2
$err->{"reason"} // do {
my $str;
&try(sub {
$str = sprintf($err->{"format"}, @{$$err{"args"};});
}
, &catch(sub {
$str = terse_dump([$_, $err->{"format"}, @{$err->{"args"};}]);
}
));
$str
}
$err->{"reason"}
do {
my $str;
&try(sub {
$str = sprintf($err->{"format"}, @{$$err{"args"};});
}
, &catch(sub {
$str = terse_dump([$_, $err->{"format"}, @{$err->{"args"};}]);
}
));
$str
}
Truth table66%2/3
A // B
A= $err->{"reason"}B= do {
my $str;
&try(sub {
$str = sprintf($err->{"format"}, @{$$err{"args"};});
}
, &catch(sub {
$str = terse_dump([$_, $err->{"format"}, @{$err->{"args"};}]);
}
));
$str
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 8 | my $str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 8 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 8 | $str = sprintf($err->{format}, @{$err->{args}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $str = terse_dump([$_, $err->{format}, @{$err->{args}}]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 8 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 9 | $diag->{range} = $self->make_line_range($err->{tmpl_line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 9 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | sub strerror2lintresult { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strerror2lintresult: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | (my MY $self, my Template $tmpl, my $errStr, my LintResult $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | $result->{info}{from} = 'strerror2lintresult'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | $result->{file} = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | $result->{diagnostics} = my Diagnostic $diag = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | $diag->{severity} = DiagnosticSeverity__Error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # Keep the whole message (perl may report several errors at once); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # the range comes from the first reported line. GH-269 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | $errStr =~ s/\n+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | $diag->{message} = $errStr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | if ($errStr =~ / line (\d+)[,\.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # make_line_range takes a 0-based line (cf. yatterror2lintresult). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | $diag->{range} = $self->make_line_range($1 - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 8 | ▶ | sub backtrace2list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
backtrace2list: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 8 | (my MY $self, my $trace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 8 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 8 | ▶ | while (my $frame = $trace->next_frame) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | push @list, +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 196 | map {$_ => $frame->$_()} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | package filename line subroutine | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 8 | \@list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # $lineno is 0-based (LSP). Callers holding 1-based lines (Part startln, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # Sub::Identify) must subtract 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 50 | ▶ | sub make_line_range { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_line_range: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 50 | (my MY $self, my $lineno) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 50 | my Range $range = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 50 | $range->{start} = $self->make_line_position($lineno); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 50 | $range->{end} = $self->make_line_position($lineno+1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 50 | $range | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 114 | ▶ | sub alttree { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alttree: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 114 | (my MY $self, my ($tmpl, $tree)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 114 | my $converter = YATT::Lite::LRXML::AltTree->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | string => $tmpl->cget('string'), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | with_source => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 114 | [$converter->convert_tree($tree)]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 36 | ▶ | sub lookup_symbol_definition { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 36 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 36 | ▶ | unless (defined $sym->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | Carp::croak "kind in SymbolInfo is empty! " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | . terse_dump($sym); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 36 | ▶ | my $sub = $self->can("lookup_symbol_definition_of__$sym->{kind}") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 35 | $sub->($self, $sym, $cursor); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 12 | ▶ | sub lookup_symbol_definition_of__ELEMENT { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ELEMENT: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 12 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 12 | my Position $pos = $sym->{refpos}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 12 | ▶ | return unless $cursor; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 12 | ▶ | my AltNode $node = $cursor->{array}[$cursor->{index}] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # A callable variable in scope (<yatt:body/>, <yatt:cb/> for cb=[code], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # <yatt:my f:code=...>) shadows a widget of the same name, as in | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # CGen::Perl::gen_call. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 12 | ▶ | if (my VarInfo $var = $self->locate_callable_var_of_element($node, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 7 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 7 | ▶ | $loc->{uri} = $self->filename2uri($var->{filename} // $sym->{filename}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$var->{"filename"} // $sym->{"filename"}
MC/DC0%0/2
$var->{"filename"} // $sym->{"filename"}
$var->{"filename"}
$sym->{"filename"}
Truth table33%1/3
A // B
A= $var->{"filename"}B= $sym->{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 7 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 7 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # Macro elements (yatt:if, yatt:foreach, ...) have no definition. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | $node->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 5 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 4 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 4 | $loc->{uri} = $self->filename2uri($self->part_filename($widget)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 4 | $loc->{range} = $self->part_decl_range($widget); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 4 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 11 | ▶ | sub lookup_symbol_definition_of__var { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__var: called CC=4 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 11 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 11 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 11 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # args and <yatt:my> vars are always defined in the file of the cursor. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 11 | ▶ | $loc->{uri} = $self->filename2uri($var->{filename} // $sym->{filename}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$var->{"filename"} // $sym->{"filename"}
MC/DC0%0/2
$var->{"filename"} // $sym->{"filename"}
$var->{"filename"}
$sym->{"filename"}
Truth table33%1/3
A // B
A= $var->{"filename"}B= $sym->{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 11 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 11 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | if (my EntityInfo $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $loc->{uri} = $self->filename2uri($entFunc->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # {line} is 1-based (Part startln / Sub::Identify). GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $loc->{range} = $self->make_line_range($entFunc->{line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 4 | ▶ | sub lookup_symbol_definition_of__call { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__call: called CC=4 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 4 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 4 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 4 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # args and <yatt:my> vars are always defined in the file of the cursor. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | $loc->{uri} = $self->filename2uri($var->{filename} // $sym->{filename}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$var->{"filename"} // $sym->{"filename"}
MC/DC0%0/2
$var->{"filename"} // $sym->{"filename"}
$var->{"filename"}
$sym->{"filename"}
Truth table0%0/3
A // B
A= $var->{"filename"}B= $sym->{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 4 | ▶ | if (my EntityInfo $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 4 | $loc->{uri} = $self->filename2uri($entFunc->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # {line} is 1-based (Part startln / Sub::Identify). GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 4 | $loc->{range} = $self->make_line_range($entFunc->{line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 4 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # Attributes at a widget call site. GH-277 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | # (see CGen::Perl::gen_putargs and passThruVar) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # <yatt:foo x/> passes the variable x in scope to formal arg x | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # (a flag when there is no such variable) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # <yatt:foo a=y/> passes the variable y in scope to formal arg a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | # <yatt:foo b="..."/> b is a formal arg; entities in the value are | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | # resolved through the entpath subtree as before | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | # <:yatt:d>...</:yatt:d> d is a formal arg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | ▶ | sub lookup_symbol_definition_of__ATTRIBUTE { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATTRIBUTE: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 2 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 2 | ▶ | $self->variable_location($sym, $cursor, $name) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->variable_location($sym, $cursor, $name) // $self->formal_arg_location($sym, $cursor, $name)
MC/DC0%0/2
$self->variable_location($sym, $cursor, $name) // $self->formal_arg_location($sym, $cursor, $name)
$self->variable_location($sym, $cursor, $name)
$self->formal_arg_location($sym, $cursor, $name)
Truth table66%2/3
A // B
A= $self->variable_location($sym, $cursor, $name)B= $self->formal_arg_location($sym, $cursor, $name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | // $self->formal_arg_location($sym, $cursor, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 3 | ▶ | sub lookup_symbol_definition_of__ATT_BARENAME { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_BARENAME: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 3 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 3 | ▶ | if ($node->{value_range} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"value_range"} and $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
MC/DC50%1/2
$node->{"value_range"} and $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
$node->{"value_range"}
$self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
Truth table66%2/3
A and B
A= $node->{"value_range"}B= $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | and $self->is_in_range($node->{value_range}, $sym->{refpos})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 2 | return $self->variable_location($sym, $cursor, $node->{value}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | $self->formal_arg_location($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 2 | ▶ | sub lookup_symbol_definition_of__ATT_TEXT { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_TEXT: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 2 | $self->formal_arg_location($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | ▶ | sub lookup_symbol_definition_of__ATT_NESTED { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_NESTED: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 1 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 1 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # Only attribute elements (<:yatt:d>) have a symbol_range. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | ▶ | return unless $node->{symbol_range}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 1 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | ▶ | return unless @path and not grep {ref $_} @path; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@path and not grep({ref $_;} @path)
MC/DC0%0/2
@path and not grep({ref $_;} @path)
@path
not grep({ref $_;} @path)
Truth table33%1/3
A and not(B)
A= @pathB= not grep({ref $_;} @path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | $self->formal_arg_location($sym, $cursor, $path[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # The ELEMENT node which owns the attribute at $cursor, if any. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 7 | ▶ | sub parent_element_of_cursor { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent_element_of_cursor: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 7 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 7 | ▶ | my Zipper $parent = $cursor->{path} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 7 | ▶ | my AltNode $elem = $parent->{array}[$parent->{index}] or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 7 | ▶ | return unless defined $elem->{kind} and $elem->{kind} eq 'ELEMENT'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $elem->{"kind"} and $elem->{"kind"} eq "ELEMENT"
MC/DC0%0/2
defined $elem->{"kind"} and $elem->{"kind"} eq "ELEMENT"
defined $elem->{"kind"}
$elem->{"kind"} eq "ELEMENT"
Truth table33%1/3
A and B
A= defined $elem->{"kind"}B= $elem->{"kind"} eq "ELEMENT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 7 | $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # ($widget, $var, $range) of the formal argument $argName of the widget | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # called by the element which owns the attribute at $cursor, or (). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 7 | ▶ | sub locate_formal_arg { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_formal_arg: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 7 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 7 | ▶ | my AltNode $elem = $self->parent_element_of_cursor($cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 7 | my Position $pos = $sym->{refpos}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | $elem->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 7 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 6 | ▶ | return unless UNIVERSAL::isa($widget, 'YATT::Lite::Core::Widget'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 6 | ▶ | my $arg = $widget->{_arg_dict}{$argName} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 6 | ▶ | my $range = $self->arg_range_map_of_part($widget)->{$argName} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition20%1/5
$self->arg_range_map_of_part($widget)->{$argName} // $self->make_line_range(($arg->lineno // 1) - 1)
$arg->lineno // 1
MC/DC0%0/2
$self->arg_range_map_of_part($widget)->{$argName} // $self->make_line_range(($arg->lineno // 1) - 1)
$self->arg_range_map_of_part($widget)->{$argName}
$self->make_line_range(($arg->lineno // 1) - 1)
MC/DC0%0/1
$arg->lineno // 1
$arg->lineno
Truth table33%1/3
A // B
A= $self->arg_range_map_of_part($widget)->{$argName}B= $self->make_line_range(($arg->lineno // 1) - 1)
Truth table0%0/2
A
A= $arg->lineno
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | // $self->make_line_range(($arg->lineno // 1) - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 6 | ($widget, $arg, $range); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 5 | ▶ | sub formal_arg_location { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formal_arg_location: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 5 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 5 | ▶ | my ($widget, $arg, $range) = $self->locate_formal_arg($sym, $cursor, $argName) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 4 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 4 | $loc->{uri} = $self->filename2uri($self->part_filename($widget)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 4 | $loc->{range} = $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 4 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # Location of the variable $name visible at $cursor (args, <yatt:my>). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | ▶ | sub variable_location { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variable_location: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 4 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 4 | my SymbolInfo $varSym = +{%$sym}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 4 | $varSym->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 4 | ▶ | my VarInfo $var = $self->locate_entity_var($varSym, $cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 3 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 3 | ▶ | $loc->{uri} = $self->filename2uri($var->{filename} // $sym->{filename}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$var->{"filename"} // $sym->{"filename"}
MC/DC0%0/2
$var->{"filename"} // $sym->{"filename"}
$var->{"filename"}
$sym->{"filename"}
Truth table33%1/3
A // B
A= $var->{"filename"}B= $sym->{"filename"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 3 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 3 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 2 | ▶ | sub describe_symbol_of_ATTRIBUTE { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATTRIBUTE: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 2 | ▶ | $self->describe_variable($sym, $cursor, $name) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->describe_variable($sym, $cursor, $name) // $self->describe_formal_arg($sym, $cursor, $name)
MC/DC0%0/2
$self->describe_variable($sym, $cursor, $name) // $self->describe_formal_arg($sym, $cursor, $name)
$self->describe_variable($sym, $cursor, $name)
$self->describe_formal_arg($sym, $cursor, $name)
Truth table66%2/3
A // B
A= $self->describe_variable($sym, $cursor, $name)B= $self->describe_formal_arg($sym, $cursor, $name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | // $self->describe_formal_arg($sym, $cursor, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | ▶ | sub describe_symbol_of_ATT_BARENAME { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_BARENAME: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | ▶ | if ($node->{value_range} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"value_range"} and $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
MC/DC50%1/2
$node->{"value_range"} and $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
$node->{"value_range"}
$self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
Truth table66%2/3
A and B
A= $node->{"value_range"}B= $self->is_in_range($node->{"value_range"}, $sym->{"refpos"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | and $self->is_in_range($node->{value_range}, $sym->{refpos})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 1 | return $self->describe_variable($sym, $cursor, $node->{value}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 1 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | $self->describe_formal_arg($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | sub describe_symbol_of_ATT_TEXT { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_TEXT: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | return unless defined $name and not ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table0%0/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $self->describe_formal_arg($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | sub describe_symbol_of_ATT_NESTED { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_NESTED: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | return unless $node->{symbol_range}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | return unless @path and not grep {ref $_} @path; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@path and not grep({ref $_;} @path)
MC/DC0%0/2
@path and not grep({ref $_;} @path)
@path
not grep({ref $_;} @path)
Truth table0%0/3
A and not(B)
A= @pathB= not grep({ref $_;} @path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $self->describe_formal_arg($sym, $cursor, $path[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 3 | ▶ | sub describe_variable { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_variable: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 3 | my SymbolInfo $varSym = +{%$sym}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 3 | $varSym->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 3 | ▶ | my VarInfo $var = $self->locate_entity_var($varSym, $cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 2 | $self->describe_entity_var($varSym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | ▶ | sub describe_formal_arg { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_formal_arg: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 2 | ▶ | my ($widget, $arg) = $self->locate_formal_arg($sym, $cursor, $argName) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | $md->{value} = $self->md_quote_code_as( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | yatt => "argument $argName of <" . $widget->callsite_name . ">: " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | . $arg->spec_string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | $md; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 33 | ▶ | sub filename2uri { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename2uri: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 33 | (my MY $self, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 33 | URI::file->new_abs($fn)->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 62 | ▶ | sub part_filename { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_filename: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 62 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 62 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 62 | $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 14 | ▶ | sub describe_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 14 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 14 | ▶ | unless (defined $sym->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | Carp::croak "kind in SymbolInfo is empty! " | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | . terse_dump($sym); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 14 | ▶ | my $resolver = $self->can("describe_symbol_of_$sym->{kind}") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 14 | $resolver->($self, $sym, $cursor); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 5 | ▶ | sub describe_symbol_of_ELEMENT { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ELEMENT: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 5 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 5 | ▶ | return unless $cursor; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 5 | ▶ | my AltNode $node = $cursor->{array}[$cursor->{index}] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 5 | my Position $pos = $self->range_start($sym->{range}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 5 | my $wname = join(":", lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # Callable variable first, as in gen_call. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 5 | ▶ | if (my VarInfo $var = $self->locate_callable_var_of_element($node, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 3 | return $self->describe_entity_var($sym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | # Builtin macros like yatt:if, yatt:foreach, ... GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 2 | ▶ | if ($self->macro_method_of_element($node, $sym->{filename}, $pos->{line})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | $md->{value} = $self->md_quote_code_as(yatt => "(macro) <$wname>"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 1 | return $md; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | $node->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | $md->{value} = $self->widget_signature_md($widget, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 1 | $md; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 2 | ▶ | sub describe_symbol_of_call { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_call: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 2 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor, [qw(code expr)])) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 1 | return $self->describe_entity_var($sym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 1 | ▶ | if (my $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 1 | return $self->describe_entity_function($sym, $entFunc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 3 | ▶ | sub describe_symbol_of_var { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_var: called CC=3 SCAR=15.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 3 | return $self->describe_entity_var($sym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | if (my $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | return $self->describe_entity_function($sym, $entFunc); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # <yatt:NAME .../> calls the callable variable NAME (code/delegate) when | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # one is in scope; CGen::Perl::gen_call looks it up before widgets, and | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # only as_varcall_code / as_varcall_delegate exist. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 17 | ▶ | sub locate_callable_var_of_element { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_callable_var_of_element: called CC=8 SCAR=21.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 17 | (my MY $self, my AltNode $node, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 17 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 17 | ▶ | return unless @path == 2 and defined $path[1] and not ref $path[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@path == 2 and defined $path[1] and not ref $path[1]
@path == 2 and defined $path[1]
MC/DC33%1/3
@path == 2 and defined $path[1] and not ref $path[1]
@path == 2
defined $path[1]
not ref $path[1]
Truth table50%2/4
A and B and not(C)
A= @path == 2B= defined $path[1]C= not ref $path[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 16 | my SymbolInfo $varSym = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 16 | $varSym->{name} = $path[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 16 | ▶ | my VarInfo $var = $self->locate_entity_var($varSym, $cursor) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 10 | ▶ | my ($type) = split /:/, ($var->{type} // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$var->{"type"} // ""
MC/DC0%0/1
$var->{"type"} // ""
$var->{"type"}
Truth table50%1/2
A
A= $var->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 10 | ▶ | return unless defined $type and $type =~ /^(?:code|delegate)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $type and $type =~ /^(?:code|delegate)\z/
MC/DC0%0/2
defined $type and $type =~ /^(?:code|delegate)\z/
defined $type
$type =~ /^(?:code|delegate)\z/
Truth table33%1/3
A and B
A= defined $typeB= $type =~ /^(?:code|delegate)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 10 | $var; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | # The macro_* method CGen::Perl::from_element would dispatch this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | # element to, or undef. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 2 | ▶ | sub macro_method_of_element { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
macro_method_of_element: called CC=5 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 2 | (my MY $self, my AltNode $node, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 2 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 2 | ▶ | return unless @path == 2 and not grep {ref $_} @path; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@path == 2 and not grep({ref $_;} @path)
MC/DC0%0/2
@path == 2 and not grep({ref $_;} @path)
@path == 2
not grep({ref $_;} @path)
Truth table33%1/3
A and not(B)
A= @path == 2B= not grep({ref $_;} @path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 2 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 2 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | my $cgen = $core->build_cgen_of('perl'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 2 | ▶ | $cgen->can("macro_" . join("_", @path)) || $cgen->can("macro_$path[-1]"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 9 | ▶ | sub describe_entity_var { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entity_var: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 9 | (my MY $self, my SymbolInfo $sym, my VarInfo $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 9 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 9 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 9 | my $text = "$var->{kind} $var->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 9 | $text .= ": $var->{type}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 9 | ▶ | $text .= "=$var->{detail}" if $var->{detail}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 9 | $md->{value} = $self->md_quote_code_as(yatt => $text); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 9 | return $md; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 1 | ▶ | sub describe_entity_function { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entity_function: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 1 | (my MY $self, my SymbolInfo $sym, my EntityInfo $entFunc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 1 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 1 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 1 | my $text = "function $sym->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 1 | $md->{value} = $self->md_quote_code_as(yatt => $text); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 1 | return $md; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 43 | ▶ | sub locate_entity_var { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_entity_var: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 43 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $ofType) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # $ofType: type name, or an ARRAY of type names. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 43 | ▶ | for (my Zipper $c = $cursor; $c; $c = $c->{path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 78 | ▶ | if (my $defs = $c->{defs}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 43 | ▶ | if (my VarInfo $var = $defs->{$sym->{name}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | next if defined $ofType | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 30 | ▶ | and not grep {$var->{type} eq $_} lexpand($ofType); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ofType and not grep({$var->{"type"} eq $_;} lexpand($ofType))
MC/DC0%0/2
defined $ofType and not grep({$var->{"type"} eq $_;} lexpand($ofType))
defined $ofType
not grep({$var->{"type"} eq $_;} lexpand($ofType))
Truth table66%2/3
A and not(B)
A= defined $ofTypeB= not grep({$var->{"type"} eq $_;} lexpand($ofType))
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 30 | return $var; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 5 | ▶ | sub locate_entity_function { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_entity_function: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 5 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 5 | my ($tmpl, $core) = $self->find_template($sym->{filename}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 5 | $self->find_entity_from($tmpl, $sym->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 14 | ▶ | sub md_quote_code_as { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
md_quote_code_as: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 14 | (my MY $self, my ($langId, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 14 | my $pre = q{```}.$langId."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 14 | $text =~ s/\n*\z/\n/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 14 | $pre.$text.q{```}."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 1 | ▶ | sub widget_signature_md { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
widget_signature_md: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 1 | (my MY $self, my Widget $widget, my $detail) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 1 | my $wname = $widget->callsite_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | my $args = join("", map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 1 | my $var = $widget->{_arg_dict}{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 1 | ▶ | " ".join("=", $_, q{"}.$var->spec_string.q{"}).($detail ? "\n" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 1 | } @{$widget->{_arg_order}}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 1 | ▶ | if ($detail) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 1 | $self->md_quote_code_as(yatt => "($widget->{kind}) <$wname$args/>"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | $args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | ▶ | sub list_parts_in { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_parts_in: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | foreach my Part $part ($tmpl->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | push @result, my DocumentSymbol $sym = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | $sym->{name} = "$part->{kind} $part->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | $sym->{kind} = $part->isa(Widget) ? SymbolKind__Constructor | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | : SymbolKind__Method; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | if ($part->isa(Widget)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | $sym->{detail} = $self->widget_signature_md($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | $sym->{range} = $self->part_decl_range($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $sym->{selectionRange} = $self->part_decl_range($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 13 | ▶ | sub lookup_widget_from { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_widget_from: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 13 | (my MY $self, my ($wpath, $fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 13 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 13 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 13 | $core->build_cgen_of('perl') | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | ->with_template($tmpl, lookup_widget => lexpand($wpath)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 57 | ▶ | sub locate_symbol_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_symbol_at_file_position: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 57 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 57 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 57 | ▶ | $column //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$column //= 0
MC/DC0%0/1
$column //= 0
$column
Truth table50%1/2
A
A= $column
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 57 | ▶ | my Zipper $cursor = $self->locate_node_at_file_position( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | $fileName, $line, $column | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 54 | ▶ | my AltNode $node = $cursor->{array}[$cursor->{index}] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # The placeholder locate_node inserts (undef, or {} if something | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | # autovivified it) is not a symbol. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 52 | ▶ | return unless defined $node->{kind}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 52 | my SymbolInfo $info = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 52 | $info->{kind} = $node->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 52 | $info->{name} = join(":", lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 52 | $info->{range} = $node->{symbol_range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 52 | $info->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 52 | $info->{refpos} = my Position $pos = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 52 | $pos->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 52 | $pos->{character} = $column; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 52 | ▶ | wantarray ? ($info, $cursor) : $info; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 28 | ▶ | sub is_debug_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debug_enabled: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 28 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 28 | ▶ | defined $self->{dir} && -e "$self->{dir}/DEBUG_YATT_LANGSERVER"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 28 | ▶ | sub debug_log { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_log: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 28 | (my MY $self, my @message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 28 | ▶ | return unless $self->is_debug_enabled; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | print STDERR "[YATT::Lite::Inspector] ", @message, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | sub get_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file_line: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | (my MY $self, my ($fileName, $lineNumber)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | my ($tmpl) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | return unless $tmpl && defined $tmpl->{string}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tmpl and defined $tmpl->{"string"}
MC/DC0%0/2
$tmpl and defined $tmpl->{"string"}
$tmpl
defined $tmpl->{"string"}
Truth table0%0/3
A and B
A= $tmplB= defined $tmpl->{"string"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | # Split template string into lines | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | my @lines = split /\n/, $tmpl->{string}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | ▶ | return $lines[$lineNumber] if $lineNumber < @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | ▶ | sub get_completion_items { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_completion_items: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | (my MY $self, my ($fileName, $line, $column, $triggerCharacter)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | $self->debug_log("get_completion_items called: file=$fileName, line=$line, column=$column, trigger='" . ($triggerCharacter // 'undef') . "'"); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$triggerCharacter // "undef"
MC/DC0%0/1
$triggerCharacter // "undef"
$triggerCharacter
Truth table0%0/2
A
A= $triggerCharacter
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | # Get active namespaces | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | my @namespaces = lexpand($self->{_SITE}->cget('namespace')); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | @namespaces = ('yatt') unless @namespaces; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | $self->debug_log("Active namespaces: " . join(", ", @namespaces)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | # Get the current line text | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | my $lineText = $self->get_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | ▶ | return unless defined $lineText; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | $self->debug_log("Line text: '$lineText'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # Extract the prefix before cursor position | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | my $prefix = substr($lineText, 0, $column); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | $self->debug_log("Prefix before cursor: '$prefix'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | # Determine completion context | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # Create namespace pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | my $ns_pattern = join('|', map { quotemeta } @namespaces); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | # Check for widget or entity completion | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | ▶ | if ($prefix =~ /<($ns_pattern):(\w*(?::\w*)*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | # Widget completion: <namespace:widgetname | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | my $widgetPath = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | $self->debug_log("Widget completion detected: namespace=$namespace, path='$widgetPath'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | push @items, $self->complete_widgets($fileName, $namespace, $widgetPath); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | elsif ($prefix =~ /&($ns_pattern):(\w*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | # Entity completion: &namespace:entity | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | my $entityName = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | $self->debug_log("Entity completion detected: namespace=$namespace, name='$entityName'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 0 | push @items, $self->complete_entities($fileName, $namespace, $entityName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | elsif ($prefix =~ /<!($ns_pattern):(\w*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | # Declaration completion: <!namespace:declaration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | my $declName = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $self->debug_log("Declaration completion detected: namespace=$namespace, name='$declName'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | push @items, $self->complete_declarations($fileName, $namespace, $declName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $self->debug_log("No completion pattern matched"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | # TODO: Widget argument completion | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | $self->debug_log("Returning " . scalar(@items) . " completion items"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | return @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | sub complete_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | (my MY $self, my ($fileName, $namespace, $widgetPath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | $self->debug_log("complete_widgets: widgetPath='$widgetPath'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | my @path = split /:/, $widgetPath; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | ▶ | my $partialName = pop @path // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
pop @path // ""
MC/DC0%0/1
pop @path // ""
pop @path
Truth table0%0/2
A
A= pop @path
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | $self->debug_log("Widget path parts: [" . join(", ", @path) . "], partial='$partialName'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # 1. First, add macro widgets (built-in widgets have highest priority) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | push @items, $self->complete_macro_widgets($fileName, $namespace, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | $self->debug_log("Found " . scalar(grep { $_->{detail} =~ /macro/ } @items) . " macro widgets"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | # 2. Then search for user-defined widgets | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | ▶ | if (@path) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | # Complex path like foo:bar:w* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | push @items, $self->complete_widgets_with_path($fileName, $namespace, \@path, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | # Simple completion like w* | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | push @items, $self->complete_widgets_simple($fileName, $namespace, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # Remove duplicates while preserving order | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | my @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | foreach my $item (@items) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | next if $seen{$item->{label}}++; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | push @unique, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | return @unique; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 2 | ▶ | sub complete_entities { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entities: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 2 | (my MY $self, my ($fileName, $namespace, $prefix, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 2 | $self->debug_log("complete_entities: prefix='$prefix', line=$line"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 2 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | # 1. Entity macros (highest priority) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 2 | push @items, $self->complete_entity_macros($fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 2 | $self->debug_log("Found " . scalar(grep { $_->{detail} =~ /entity macro/ } @items) . " entity macros"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | # 2. Variables (widget arguments) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 2 | my $var_count_before = @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 2 | push @items, $self->complete_entity_variables($fileName, $namespace, $prefix, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 2 | my $var_count = scalar(grep { $_->{kind} == 13 } @items) - scalar(grep { $_->{kind} == 13 } @items[0..$var_count_before-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 2 | $self->debug_log("Found $var_count variables"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | # 3. Entity functions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 2 | my $func_count_before = @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 2 | push @items, $self->complete_entity_functions($fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 2 | $self->debug_log("Found " . (@items - $func_count_before) . " entity functions"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # Remove duplicates while preserving order | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 2 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | my @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 2 | foreach my $item (@items) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 94 | ▶ | next if $seen{$item->{label}}++; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 94 | push @unique, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | # Sort to show variables first, then entity macros, then entity functions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | my @sorted = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | # Variables (kind == 13) come first | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 2 | ▶ | my $a_is_var = $a->{kind} == 13 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 457 | ▶ | my $b_is_var = $b->{kind} == 13 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 457 | ▶ | if ($a_is_var != $b_is_var) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 21 | return $a_is_var <=> $b_is_var; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | # Then entity macros | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 436 | ▶ | my $a_is_macro = ($a->{detail} && $a->{detail} =~ /entity macro/) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$YATT::Lite::Inspector::a->{"detail"} and $YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
MC/DC50%1/2
$YATT::Lite::Inspector::a->{"detail"} and $YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
$YATT::Lite::Inspector::a->{"detail"}
$YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
Truth table66%2/3
A and B
A= $YATT::Lite::Inspector::a->{"detail"}B= $YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 436 | ▶ | my $b_is_macro = ($b->{detail} && $b->{detail} =~ /entity macro/) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$YATT::Lite::Inspector::b->{"detail"} and $YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
MC/DC50%1/2
$YATT::Lite::Inspector::b->{"detail"} and $YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
$YATT::Lite::Inspector::b->{"detail"}
$YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
Truth table66%2/3
A and B
A= $YATT::Lite::Inspector::b->{"detail"}B= $YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 436 | ▶ | if ($a_is_macro != $b_is_macro) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 24 | return $a_is_macro <=> $b_is_macro; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | # Finally sort by label | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 412 | return $a->{label} cmp $b->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 2 | $self->debug_log("Total unique entities: " . scalar(@sorted)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 2 | return @sorted; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | ▶ | sub complete_macro_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_macro_widgets: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # Get the code generator | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | my $cgen = $core->build_cgen_of('perl'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | # Find all macro_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ▶ | my $cgen_class = ref($cgen) || $cgen; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $cgen || $cgen
MC/DC0%0/2
ref $cgen || $cgen
ref $cgen
$cgen
Truth table0%0/3
A || B
A= ref $cgenB= $cgen
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | my @methods = $self->list_methods_starting_with($cgen_class, 'macro_'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | my $widget_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | $widget_name =~ s/^macro_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | next unless $widget_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | $item->{label} = $widget_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | $item->{kind} = SymbolKind__Constructor; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | $item->{detail} = "macro $namespace:$widget_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | $item->{documentation} = "Built-in macro widget"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | ▶ | sub complete_widgets_simple { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_simple: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | return unless $tmpl && $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tmpl and $core
MC/DC0%0/2
$tmpl and $core
$tmpl
$core
Truth table0%0/3
A and B
A= $tmplB= $core
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # Search in current template first | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | foreach my Widget $widget ($tmpl->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | next if $widget->{name} eq ''; # Skip default widget | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | next unless $widget->{name} =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | push @items, $self->make_widget_completion_item($widget, $namespace); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # Search in current directory and inherited directories | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | ▶ | if (my Folder $folder = $tmpl->{parent}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | push @items, $self->complete_widgets_in_folder_recursive($folder, $fileName, $namespace, $prefix, $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | sub complete_widgets_with_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_with_path: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | (my MY $self, my ($fileName, $namespace, $pathRef, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | my @path = @$pathRef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | return unless $tmpl && $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tmpl and $core
MC/DC0%0/2
$tmpl and $core
$tmpl
$core
Truth table0%0/3
A and B
A= $tmplB= $core
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | # Try with namespace first, then without | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | ▶ | my $target = $core->find_part_from($tmpl, $namespace, @path) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$core->find_part_from($tmpl, $namespace, @path) || $core->find_part_from($tmpl, @path)
MC/DC0%0/2
$core->find_part_from($tmpl, $namespace, @path) || $core->find_part_from($tmpl, @path)
$core->find_part_from($tmpl, $namespace, @path)
$core->find_part_from($tmpl, @path)
Truth table0%0/3
A || B
A= $core->find_part_from($tmpl, $namespace, @path)B= $core->find_part_from($tmpl, @path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | || $core->find_part_from($tmpl, @path); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | if ($target) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | ▶ | if ($target->isa($self->Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | # Found a template file, complete widgets within it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | foreach my Widget $widget ($target->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | ▶ | next if $widget->{name} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | next unless $widget->{name} =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | foreach my CompletionItem $item ($self->make_widget_completion_item($widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | # Adjust label to include full path | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my $full_path = join(':', @path, $widget->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | my $original_label = $item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | $item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | $item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | $item->{detail} = "widget $namespace:" . $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | $item->{filterText} = $full_path; # Update filter text too | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | } elsif ($target->isa('YATT::Lite::VFS::Folder')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | # Found a folder, complete files/widgets within it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | push @items, $self->complete_widgets_in_folder($target, $fileName, $namespace, $prefix, undef, \@path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | ▶ | sub complete_widgets_in_folder_recursive { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_in_folder_recursive: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | (my MY $self, my Folder $folder, my ($fileName, $namespace, $prefix, $exclude_tmpl)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | # Search current folder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | push @items, $self->complete_widgets_in_folder($folder, $fileName, $namespace, $prefix, $exclude_tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | # Search in base folders (inheritance) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | my @queue = ($folder); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | while (@queue) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my Folder $cur = shift @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | ▶ | next if $seen{$cur}++; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | if (my $base = $cur->{base}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | ▶ | my @bases = ref($base) eq 'ARRAY' ? @$base : $base; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | foreach my Folder $base_folder (@bases) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | push @items, $self->complete_widgets_in_folder($base_folder, $fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | push @queue, $base_folder; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 0 | ▶ | sub complete_widgets_in_folder { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_in_folder: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | (my MY $self, my Folder $folder, my ($fileName, $namespace, $prefix, $exclude_tmpl, $pathPrefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | $pathPrefix //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$pathPrefix //= []
MC/DC0%0/1
$pathPrefix //= []
$pathPrefix
Truth table0%0/2
A
A= $pathPrefix
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | # Refresh folder to ensure we have latest content | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | $folder->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | # Get all parts in this folder | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | foreach my Part $part ($folder->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | next unless $part; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | ▶ | if ($part->isa($self->Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | my Template $tmpl = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | ▶ | next if $exclude_tmpl && $tmpl == $exclude_tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$exclude_tmpl and $tmpl == $exclude_tmpl
MC/DC0%0/2
$exclude_tmpl and $tmpl == $exclude_tmpl
$exclude_tmpl
$tmpl == $exclude_tmpl
Truth table0%0/3
A and B
A= $exclude_tmplB= $tmpl == $exclude_tmpl
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | # Extract base name without extension | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | my $base_name = $tmpl->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | ▶ | $base_name =~ s/\.\w+$// if defined $base_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | # Check if this matches our prefix | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | ▶ | if ($base_name && $base_name =~ /^\Q$prefix/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$base_name and $base_name =~ /^\Q$prefix\E/
MC/DC0%0/2
$base_name and $base_name =~ /^\Q$prefix\E/
$base_name
$base_name =~ /^\Q$prefix\E/
Truth table0%0/3
A and B
A= $base_nameB= $base_name =~ /^\Q$prefix\E/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | # File name matches - suggest the file itself (default widget) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 0 | ▶ | if (my $default_widget = $tmpl->{_Item}{''}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | foreach my CompletionItem $comp_item ($self->make_widget_completion_item($default_widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | ▶ | my $full_path = @$pathPrefix ? join(':', @$pathPrefix, $base_name) : $base_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | my $original_label = $comp_item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | $comp_item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | $comp_item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | $comp_item->{detail} = "template $namespace:$full_path (default widget)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | $comp_item->{filterText} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | # Fix insertText for default widgets (which have empty name) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | ▶ | if ($comp_item->{insertTextFormat} == InsertTextFormat__Snippet) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | # Replace empty widget name with the actual path in snippet | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | $comp_item->{insertText} =~ s/^>/$full_path>/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | $comp_item->{insertText} =~ s/<\/\Q$namespace\E:>/<\/$namespace:$full_path>/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | # Replace empty widget name in plain text | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | $comp_item->{insertText} =~ s/^\/>/$full_path\/>/; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | push @items, $comp_item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # Also suggest widgets within this file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | foreach my Widget $widget ($tmpl->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | next if $widget->{name} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | foreach my CompletionItem $comp_item ($self->make_widget_completion_item($widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | my $full_path = @$pathPrefix | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | ? join(':', @$pathPrefix, $base_name, $widget->{name}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | : join(':', $base_name, $widget->{name}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 0 | my $original_label = $comp_item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | $comp_item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | $comp_item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | $comp_item->{detail} = "widget $namespace:$full_path"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | $comp_item->{filterText} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | push @items, $comp_item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | sub make_widget_completion_item { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_widget_completion_item: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | (my MY $self, my Widget $widget, my ($namespace)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | # We'll return multiple items for different tag styles | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | # Base item properties (shared between variants) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 0 | my $base = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | kind => SymbolKind__Function, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | detail => "widget $namespace:$widget->{name}", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | # Add argument info if available | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | my @args = $self->list_part_args_internal($widget); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | my $doc = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | my @snippet_params; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | my $param_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | my @argSpecs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | foreach my ArgSpec $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | my $spec = $arg->{varname}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | ▶ | $spec .= ": " . $arg->{type}->[0] if $arg->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | ▶ | $spec .= " (required)" if $arg->{is_required}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | push @argSpecs, $spec; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | # Build snippet parameters for required arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | ▶ | if ($arg->{is_required} && $arg->{varname} ne 'body') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg->{"is_required"} and $arg->{"varname"} ne "body"
MC/DC0%0/2
$arg->{"is_required"} and $arg->{"varname"} ne "body"
$arg->{"is_required"}
$arg->{"varname"} ne "body"
Truth table0%0/3
A and B
A= $arg->{"is_required"}B= $arg->{"varname"} ne "body"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | $param_count++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | push @snippet_params, $arg->{varname} . '="${' . $param_count . ':' . $arg->{varname} . '}"'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | ▶ | $doc = join("\n", @argSpecs) if @argSpecs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | # 1. Self-closing tag variant | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | my CompletionItem $item = { %$base }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 0 | $item->{label} = $widget->{name} . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | $item->{sortText} = $widget->{name} . "_1"; # Sort after the main variant | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | $item->{filterText} = $widget->{name}; # Filter by widget name only | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | ▶ | $item->{documentation} = $doc if $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | ▶ | if (@snippet_params) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | $item->{insertText} = $widget->{name} . ' ' . join(' ', @snippet_params) . '/>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | $item->{insertText} = $widget->{name} . '/>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | # 2. Open/close tag variant | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | my CompletionItem $item = { %$base }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | $item->{label} = $widget->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | $item->{sortText} = $widget->{name} . "_0"; # Sort before self-closing | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | $item->{filterText} = $widget->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | ▶ | $item->{documentation} = $doc if $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | my $next_pos = $param_count + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | ▶ | if (@snippet_params) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $item->{insertText} = $widget->{name} . ' ' . join(' ', @snippet_params) . '>$' . $next_pos . '</' . $namespace . ':' . $widget->{name} . '>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | $item->{insertText} = $widget->{name} . '>$1</' . $namespace . ':' . $widget->{name} . '>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | # Return list in list context, single item in scalar context (for backward compatibility) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | ▶ | wantarray ? @items : $items[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 42 | ▶ | sub list_methods_starting_with { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_methods_starting_with: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 42 | (my MY $self, my ($class, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 42 | my @methods; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 42 | my $symtab = symtab($class); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 42 | foreach my $name (keys %$symtab) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 1328 | ▶ | next unless $name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 253 | my $glob = MOP4Import::Util::globref($class, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 253 | ▶ | next unless defined *{$glob}{CODE}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 252 | push @methods, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | # Also check parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 42 | foreach my $parent (@{MOP4Import::Util::isa_array($class)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 38 | push @methods, $self->list_methods_starting_with($parent, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | # Remove duplicates | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 42 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 42 | grep { !$seen{$_}++ } @methods; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 2 | ▶ | sub complete_entity_macros { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_macros: called CC=10 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 2 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 2 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 2 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 2 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | # Get the code generator | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 2 | my $cgen = $core->build_cgen_of('perl'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # Find all entmacro_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 2 | ▶ | my $cgen_class = ref($cgen) || $cgen; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $cgen || $cgen
MC/DC0%0/2
ref $cgen || $cgen
ref $cgen
$cgen
Truth table33%1/3
A || B
A= ref $cgenB= $cgen
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 2 | my @methods = $self->list_methods_starting_with($cgen_class, 'entmacro_'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 2 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 32 | my $entity_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 32 | $entity_name =~ s/^entmacro_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 32 | ▶ | next unless $entity_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 17 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 17 | $item->{label} = $entity_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 17 | $item->{kind} = SymbolKind__Function; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 17 | $item->{detail} = "entity macro $namespace:$entity_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 17 | $item->{documentation} = "Built-in entity macro"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | # Add snippets for common entity macros | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 17 | ▶ | if ($entity_name eq 'if') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 1 | $item->{insertText} = 'if(${1:condition}, ${2:then}, ${3:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 1 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | elsif ($entity_name eq 'unless') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | $item->{insertText} = 'unless(${1:condition}, ${2:then}, ${3:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | elsif ($entity_name eq 'ifeq') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 1 | $item->{insertText} = 'ifeq(${1:a}, ${2:b}, ${3:then}, ${4:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 1 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | ▶ | elsif ($entity_name eq 'value_checked' || $entity_name eq 'value_selected') { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$entity_name eq "value_checked" or $entity_name eq "value_selected"
MC/DC100%2/2
$entity_name eq "value_checked" or $entity_name eq "value_selected"
$entity_name eq "value_checked"
$entity_name eq "value_selected"
Truth table100%3/3
A or B
A= $entity_name eq "value_checked"B= $entity_name eq "value_selected"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 2 | $item->{insertText} = $entity_name . '(${1:name}, ${2:value});'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 2 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | # Default: just add semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 13 | $item->{insertText} = $entity_name . ';'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 13 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 17 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 2 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 2 | ▶ | sub complete_entity_variables { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_variables: called CC=11 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 2 | (my MY $self, my ($fileName, $namespace, $prefix, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 2 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | # Find the part (widget) at the current line | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 2 | ▶ | (my Part $part, my Template $tmpl, my $core) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | = $self->find_part_of_file_line($fileName, $line) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | # List all arguments of the current widget | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 2 | ▶ | foreach my $argName (@{$part->{_arg_order} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$part->{'_arg_order'} || []
MC/DC0%0/1
$part->{'_arg_order'} || []
$part->{'_arg_order'}
Truth table50%1/2
A
A= $part->{'_arg_order'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 3 | ▶ | next unless $argName =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 2 | my $arg = $part->{_arg_dict}{$argName}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 2 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 2 | $item->{label} = $argName; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 2 | $item->{kind} = SymbolKind__Variable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 2 | ▶ | $item->{detail} = "var $argName" . ($arg->type ? ": " . join(":", lexpand($arg->type)) : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 2 | ▶ | if ($arg->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | $item->{documentation} = "Required argument"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # Variables just need a semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 2 | $item->{insertText} = $argName . ';'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 2 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 2 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # Page constants, unless shadowed by an argument. GH-286 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 2 | my $pagevars = $self->pagevar_defs_of_template($tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 2 | foreach my $name (sort keys %$pagevars) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 7 | ▶ | next unless $name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 4 | ▶ | next if $part->{_arg_dict}{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 3 | my VarInfo $var = $pagevars->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 3 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 3 | $item->{label} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 3 | $item->{kind} = SymbolKind__Variable; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 3 | $item->{detail} = "pagevar $name: $var->{type}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 3 | ▶ | $item->{documentation} = $var->{detail} if defined $var->{detail}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 3 | $item->{insertText} = $name . ';'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 3 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 3 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 2 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 2 | ▶ | sub complete_entity_functions { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_functions: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 2 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 2 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 2 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 2 | ▶ | return unless $tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | # Get the entns for this template | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 2 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 2 | ▶ | return unless $entns; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | # Find all entity_* methods in the entns and its parents | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 2 | my @methods = $self->list_methods_starting_with($entns, 'entity_'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 2 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 144 | my $entity_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 144 | $entity_name =~ s/^entity_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 144 | ▶ | next unless $entity_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 72 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 72 | $item->{label} = $entity_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 72 | $item->{kind} = SymbolKind__Function; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 72 | $item->{detail} = "entity $namespace:$entity_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 72 | $item->{documentation} = "User-defined entity function"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | # For entity functions, add parentheses and semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 72 | $item->{insertText} = $entity_name . '($1);'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 72 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 72 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 2 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | ▶ | sub complete_declarations { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_declarations: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | $self->debug_log("complete_declarations: prefix='$prefix'"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | # Get the parser instance | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | my $parser = $core->Parser; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | ▶ | return unless $parser; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | # Get parser class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 0 | ▶ | my $parser_class = ref($parser) || $parser; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $parser || $parser
MC/DC0%0/2
ref $parser || $parser
ref $parser
$parser
Truth table0%0/3
A || B
A= ref $parserB= $parser
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | # Find all build_* and declare_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | my @build_methods = $self->list_methods_starting_with($parser_class, 'build_'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 0 | my @declare_methods = $self->list_methods_starting_with($parser_class, 'declare_'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | # Extract declaration names | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | my %declarations; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | foreach my $method (@build_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | my $decl_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | $decl_name =~ s/^build_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | $declarations{$decl_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | foreach my $method (@declare_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | my $decl_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | $decl_name =~ s/^declare_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | $declarations{$decl_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | # Create completion items | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | foreach my $decl (sort keys %declarations) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | next unless $decl =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | $item->{label} = $decl; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | $item->{kind} = SymbolKind__Property; # Using Property as Keyword doesn't exist | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | $item->{detail} = "declaration $namespace:$decl"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | $item->{documentation} = ""; # Leave documentation empty as requested | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | # Add snippet support for declarations | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 0 | ▶ | if ($decl eq 'args') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | $item->{insertText} = "args \${1:arguments}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | elsif ($decl eq 'widget') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | $item->{insertText} = "widget \${1:name} \${2:args}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | elsif ($decl eq 'entity') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | $item->{insertText} = "entity \${1:name} \${2:params}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | elsif ($decl eq 'action') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | $item->{insertText} = "action \${1:name}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | elsif ($decl eq 'base') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | $item->{insertText} = "base \${1:file=\"../base.ytmpl\"}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | # For other declarations, just add the closing > and newline | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | $item->{insertText} = "$decl \$1>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | $self->debug_log("Found " . scalar(@items) . " declarations"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 57 | ▶ | sub locate_node_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_node_at_file_position: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 57 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 57 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 57 | ▶ | $column //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$column //= 0
MC/DC0%0/1
$column //= 0
$column
Truth table50%1/2
A
A= $column
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 57 | ▶ | my $treeSpec = $self->dump_tokens_at_file_position($fileName, $line, $column) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 56 | my Position $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 56 | $pos->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 56 | $pos->{character} = $column; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 56 | (my ($kind, $path, $range, $tree), my Part $part) = @$treeSpec; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 56 | ▶ | unless ($self->is_in_range($range, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | # e.g. cursor past the last part. Not a symbol, not an error. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 1 | $self->debug_log("position is out of part range: range=" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | .terse_dump($range)." line=$line col=$column"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | # <!yatt:action>, <!yatt:entity>... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 55 | ▶ | return if $kind eq 'body_string'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 54 | my Zipper $cursor = $self->locate_node($tree, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 54 | $self->augment_defs($cursor, $part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 54 | ▶ | sub augment_defs { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 54 | (my MY $self, my Zipper $cursor, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 54 | my $zipperList = $self->flatten_zipper_top2bottom($cursor); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 54 | my Zipper $outermost = $zipperList->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 54 | my $rangeMap = $self->arg_range_map_of_part($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 54 | my $fileName = $self->part_filename($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | $outermost->{defs}{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | //= $self->make_document_symbol_from_argument($part->{_arg_dict}{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | , $rangeMap, $fileName) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 54 | ▶ | for keys %{$part->{_arg_dict}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$outermost->{"defs"}{$_} //= $self->make_document_symbol_from_argument($part->{"_arg_dict"}{$_}, $rangeMap, $fileName)
MC/DC0%0/2
$outermost->{"defs"}{$_} //= $self->make_document_symbol_from_argument($part->{"_arg_dict"}{$_}, $rangeMap, $fileName)
$outermost->{"defs"}{$_}
$self->make_document_symbol_from_argument($part->{"_arg_dict"}{$_}, $rangeMap, $fileName)
Truth table33%1/3
A //= B
A= $outermost->{"defs"}{$_}B= $self->make_document_symbol_from_argument($part->{"_arg_dict"}{$_}, $rangeMap, $fileName)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | # Page constants form the outermost scope; arguments win. GH-286 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 54 | my $pagevars = $self->pagevar_defs_of_template($part->{folder}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 54 | ▶ | $outermost->{defs}{$_} //= $pagevars->{$_} for keys %$pagevars; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$outermost->{"defs"}{$_} //= $pagevars->{$_}
MC/DC0%0/2
$outermost->{"defs"}{$_} //= $pagevars->{$_}
$outermost->{"defs"}{$_}
$pagevars->{$_}
Truth table66%2/3
A //= B
A= $outermost->{"defs"}{$_}B= $pagevars->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 54 | $self->augment_defs_1($zipperList, 0, $fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 54 | $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | # name => Range of each argument token written in the <!yatt:...> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | # declaration. Args injected by argmacros have no token here. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | # The implicit body argument maps to the declaration line. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 60 | ▶ | sub arg_range_map_of_part { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_range_map_of_part: called CC=19 SCAR=32.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 60 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 60 | ▶ | my $decllist = $part->{_decllist} or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 60 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 60 | my %map; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | my @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | # Reversed: the first ATTRIBUTE node of widget/page/entity/action | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | # declarations is the part name itself. An argument with the same name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | # (a later node) must win. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 60 | foreach my AltNode $node (reverse @{$self->alttree($tmpl, $decllist)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | next unless defined $node->{kind} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 160 | ▶ | and $node->{kind} =~ /^(?:ATTRIBUTE|ATT_TEXT|ATT_BARENAME|ATT_NESTED)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $node->{"kind"} and $node->{"kind"} =~ /^(?:ATTRIBUTE|ATT_TEXT|ATT_BARENAME|ATT_NESTED)\z/
MC/DC0%0/2
defined $node->{"kind"} and $node->{"kind"} =~ /^(?:ATTRIBUTE|ATT_TEXT|ATT_BARENAME|ATT_NESTED)\z/
defined $node->{"kind"}
$node->{"kind"} =~ /^(?:ATTRIBUTE|ATT_TEXT|ATT_BARENAME|ATT_NESTED)\z/
Truth table33%1/3
A and B
A= defined $node->{"kind"}B= $node->{"kind"} =~ /^(?:ATTRIBUTE|ATT_TEXT|ATT_BARENAME|ATT_NESTED)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 160 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 160 | ▶ | next if not defined $name or ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $name or ref $name
MC/DC0%0/2
not defined $name or ref $name
not defined $name
ref $name
Truth table33%1/3
not(A) or B
A= not defined $nameB= ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 160 | my Range $range = $node->{symbol_range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 160 | ▶ | if (not $range and $node->{kind} eq 'ATT_NESTED' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $range and $node->{"kind"} eq "ATT_NESTED" and my YATT::Lite::LanguageServer::Protocol::Range $tree = $node->{"tree_range"}
not $range and $node->{"kind"} eq "ATT_NESTED"
MC/DC33%1/3
not $range and $node->{"kind"} eq "ATT_NESTED" and my YATT::Lite::LanguageServer::Protocol::Range $tree = $node->{"tree_range"}
not $range
$node->{"kind"} eq "ATT_NESTED"
my YATT::Lite::LanguageServer::Protocol::Range $tree = $node->{"tree_range"}
Truth table50%2/4
not(A) and B and C
A= not $rangeB= $node->{"kind"} eq "ATT_NESTED"C= my YATT::Lite::LanguageServer::Protocol::Range $tree = $node->{"tree_range"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | and (my Range $tree = $node->{tree_range})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | # cb=[code a b]: the node starts at "[", so look back on the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | # same line for the "cb=" before it. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 29 | ▶ | @lines = split /\n/, ($tmpl->{string} // '') unless @lines; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$tmpl->{"string"} // ""
MC/DC0%0/1
$tmpl->{"string"} // ""
$tmpl->{"string"}
Truth table50%1/2
A
A= $tmpl->{"string"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | 29 | ▶ | my $lineText = $lines[$tree->{start}{line}] // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$lines[$tree->{"start"}{"line"}] // ""
MC/DC0%0/1
$lines[$tree->{"start"}{"line"}] // ""
$lines[$tree->{"start"}{"line"}]
Truth table50%1/2
A
A= $lines[$tree->{"start"}{"line"}]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 29 | ▶ | if (substr($lineText, 0, $tree->{start}{character}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | =~ /(\Q$name\E)\s*=\s*\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 29 | $range = $self->make_range_on_line($tree->{start}{line}, $-[1], $+[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 160 | ▶ | $map{$name} = $range // $node->{tree_range}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$range // $node->{"tree_range"}
MC/DC0%0/2
$range // $node->{"tree_range"}
$range
$node->{"tree_range"}
Truth table33%1/3
A // B
A= $rangeB= $node->{"tree_range"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 60 | ▶ | if (my $dict = $part->{_arg_dict}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 60 | foreach my $name (keys %$dict) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 201 | ▶ | next if $map{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | 53 | my $arg = $dict->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 53 | ▶ | next unless $arg->is_body_argument; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 53 | $map{$name} = $self->part_decl_range($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 60 | \%map; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 29 | ▶ | sub make_range_on_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_range_on_line: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 29 | (my MY $self, my ($line, $startChar, $endChar)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 29 | my Range $range = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 29 | $range->{start} = +{line => $line, character => $startChar}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 29 | $range->{end} = +{line => $line, character => $endChar}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 29 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 165 | ▶ | sub make_document_symbol_from_argument { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_document_symbol_from_argument: called CC=5 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 165 | (my MY $self, my ($arg, $rangeMap, $fileName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 165 | my VarInfo $var = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 165 | $var->{name} = $arg->varname; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 165 | $var->{kind} = '(argument)'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 165 | $var->{type} = join(":", lexpand($arg->type)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 165 | ▶ | if (my $spec = $arg->spec_string) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 165 | $var->{detail} = qq{"$spec"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 165 | $var->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | # A real Range (start/end), not a Position. VarTypes lineno is 1-based. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | $var->{range} = ($rangeMap && $rangeMap->{$var->{name}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 165 | ▶ | // $self->make_line_range(($arg->lineno // 1) - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%2/8
$rangeMap && $$rangeMap{$var->{"name"}} // $self->make_line_range(($arg->lineno // 1) - 1)
$rangeMap and $$rangeMap{$var->{"name"}}
$arg->lineno // 1
MC/DC0%0/3
$rangeMap && $$rangeMap{$var->{"name"}} // $self->make_line_range(($arg->lineno // 1) - 1)
$rangeMap
$$rangeMap{$var->{"name"}}
$self->make_line_range(($arg->lineno // 1) - 1)
MC/DC0%0/1
$arg->lineno // 1
$arg->lineno
Truth table20%1/5
A and B // C
A= $rangeMapB= $$rangeMap{$var->{"name"}}C= $self->make_line_range(($arg->lineno // 1) - 1)
Truth table0%0/2
A
A= $arg->lineno
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 165 | $var; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | # Page constants (pagevars, GH-282) of the page $tmpl as name => VarInfo, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | # located in the pagevars module. Empty for non-page templates | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | # (page_name is undef) and when the module can't be loaded. GH-286 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 56 | ▶ | sub pagevar_defs_of_template { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pagevar_defs_of_template: called CC=9 SCAR=22.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 56 | (my MY $self, my Template $tmpl) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 56 | ▶ | return {} unless $tmpl and defined(my $page = $tmpl->page_name); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tmpl and defined(my $page = $tmpl->page_name)
MC/DC50%1/2
$tmpl and defined(my $page = $tmpl->page_name)
$tmpl
defined(my $page = $tmpl->page_name)
Truth table66%2/3
A and B
A= $tmplB= defined(my $page = $tmpl->page_name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | my $yatt = $self->find_yatt_for_template($tmpl->{path}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 55 | ▶ | or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 55 | ▶ | my $pagevars = $yatt->cget('pagevars') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 10 | my $consts = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | 10 | YATT::Lite::Util::ckrequire($pagevars); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 10 | $pagevars->find_consts($page); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 10 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | $self->debug_log("Can't load pagevars $pagevars: $@"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 10 | ▶ | return {} unless $consts; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 10 | my %defs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 10 | foreach my $name (keys %$consts) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 36 | my VarInfo $var = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 36 | $var->{kind} = 'pagevar'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 36 | $var->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 36 | $var->{type} = $pagevars->const_type($consts->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | $var->{detail} = $self->pagevar_value_preview($consts->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 36 | , $var->{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 36 | my ($file, $line) = $pagevars->locate_const($page, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 36 | $var->{filename} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | # locate_const returns 1-based line. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 36 | ▶ | $var->{range} = $self->make_line_range(($line // 1) - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line // 1
MC/DC0%0/1
$line // 1
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 36 | $defs{$name} = $var; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 10 | \%defs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 36 | ▶ | sub pagevar_value_preview { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pagevar_value_preview: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | 36 | (my MY $self, my ($value, $type)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | 36 | ▶ | if ($type eq 'text' or $type eq 'html') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$type eq "text" or $type eq "html"
MC/DC100%2/2
$type eq "text" or $type eq "html"
$type eq "text"
$type eq "html"
Truth table100%3/3
A or B
A= $type eq "text"B= $type eq "html"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 26 | my $str = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 26 | ▶ | $str = substr($str, 0, 40) . "..." if length $str > 43; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 26 | $str =~ s/\n/\\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 26 | qq{"$str"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | } elsif ($type eq 'list') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | 4 | sprintf "[%d items]", scalar @$value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 6 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 54 | ▶ | sub flatten_zipper_top2bottom { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flatten_zipper_top2bottom: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | 54 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 54 | my @zipper; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 54 | my Zipper $c = $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 54 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 98 | unshift @zipper, $c; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | 98 | $c = $c->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | } while $c; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 54 | ▶ | wantarray ? @zipper : \@zipper; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 54 | ▶ | sub augment_defs_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs_1: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 54 | (my MY $self, my ($zipperList, $depth, $fileName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 54 | my Zipper $zipper = $zipperList->[$depth]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 54 | my @nodes = @{$zipper->{array}}[0..$zipper->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | # $nodes[-1] may be the undef placeholder which locate_node inserts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | # when the cursor is between nodes. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 54 | my $current = $nodes[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 54 | foreach my AltNode $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 166 | ▶ | unless (defined $node and defined $node->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $node and defined $node->{"kind"}
MC/DC50%1/2
defined $node and defined $node->{"kind"}
defined $node
defined $node->{"kind"}
Truth table66%2/3
A and B
A= defined $nodeB= defined $node->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | my $method = join("_", augment_defs_1_ => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 165 | , $node->{kind}, lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 165 | ▶ | my $sub = $self->can($method) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 17 | ▶ | $sub->($self, $zipper, $node, (defined $current && $node == $current) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $current && $node == $current
MC/DC100%2/2
defined $current && $node == $current
defined $current
$node == $current
Truth table100%3/3
A && B
A= defined $currentB= $node == $current
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | , $fileName); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 17 | ▶ | sub augment_defs_1__ELEMENT_yatt_my { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs_1__ELEMENT_yatt_my: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 17 | (my MY $self, my Zipper $cursor, my AltNode $node | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | , my ($isCurrent, $fileName)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 17 | foreach my AltNode $subNode (@{$node->{subtree}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | # $subNode aliases the array element: testing $subNode->{kind} on | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | # the undef placeholder of locate_node would autovivify it. GH-280 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | 18 | ▶ | next unless defined $subNode and defined $subNode->{kind}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $subNode and defined $subNode->{"kind"}
MC/DC50%1/2
defined $subNode and defined $subNode->{"kind"}
defined $subNode
defined $subNode->{"kind"}
Truth table66%2/3
A and B
A= defined $subNodeB= defined $subNode->{"kind"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 17 | ▶ | next unless $subNode->{kind} eq "ATT_TEXT"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 17 | my ($name, @type) = lexpand($subNode->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 17 | $cursor->{defs}{$name} = my VarInfo $var = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 17 | $var->{kind} = 'my'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 17 | $var->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 17 | ▶ | $var->{type} = @type ? join(":", @type) : 'text'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 17 | ▶ | $var->{range} = $subNode->{symbol_range} // $subNode->{tree_range}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$subNode->{"symbol_range"} // $subNode->{"tree_range"}
MC/DC0%0/2
$subNode->{"symbol_range"} // $subNode->{"tree_range"}
$subNode->{"symbol_range"}
$subNode->{"tree_range"}
Truth table33%1/3
A // B
A= $subNode->{"symbol_range"}B= $subNode->{"tree_range"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | 17 | $var->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | ▶ | sub node_path_of_zipper { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_path_of_zipper: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | my @trail; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | 0 | my Zipper $cur = $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | ▶ | while ($cur) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | push @trail, do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | ▶ | if (my AltNode $node = $cur->{array}[$cur->{index}]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | $self->minimize_altnode($node); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | [map {$self->minimize_altnode($_)} @{$cur->{array}}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 0 | $cur = $cur->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | @trail; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | ▶ | sub minimize_altnode { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minimize_altnode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 0 | (my MY $self, my AltNode $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | my AltNode $min = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | $min->{kind} = $node->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | $min->{path} = $node->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | $min->{tree_range} = $node->{tree_range}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | $min; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 98 | ▶ | sub locate_node { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_node: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 98 | (my MY $self, my $tree, my Position $pos, my Zipper $parent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 98 | my Zipper $current = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 98 | $current->{path} = $parent; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 98 | $current->{array} = $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 98 | my $ix = $current->{index} = $self->lsearch_node_pos($pos, $tree); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 98 | ▶ | if (my AltNode $node = $tree->[$ix]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | 97 | ▶ | if ($node->{symbol_range} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node->{"symbol_range"} and $self->is_in_range($node->{"symbol_range"}, $pos)
MC/DC100%2/2
$node->{"symbol_range"} and $self->is_in_range($node->{"symbol_range"}, $pos)
$node->{"symbol_range"}
$self->is_in_range($node->{"symbol_range"}, $pos)
Truth table100%3/3
A and B
A= $node->{"symbol_range"}B= $self->is_in_range($node->{"symbol_range"}, $pos)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | and $self->is_in_range($node->{symbol_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 47 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 50 | ▶ | if ($node->{subtree} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$node->{"subtree"} and $self->is_in_range($node->{"tree_range"}, $pos)
MC/DC100%2/2
$node->{"subtree"} and $self->is_in_range($node->{"tree_range"}, $pos)
$node->{"subtree"}
$self->is_in_range($node->{"tree_range"}, $pos)
Truth table100%3/3
A and B
A= $node->{"subtree"}B= $self->is_in_range($node->{"tree_range"}, $pos)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | and $self->is_in_range($node->{tree_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 44 | return $self->locate_node($node->{subtree}, $pos, $current); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | ▶ | } elsif ($node->{tree_range} | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$node->{"tree_range"} and $self->is_in_range($node->{"tree_range"}, $pos)
MC/DC50%1/2
$node->{"tree_range"} and $self->is_in_range($node->{"tree_range"}, $pos)
$node->{"tree_range"}
$self->is_in_range($node->{"tree_range"}, $pos)
Truth table66%2/3
A and B
A= $node->{"tree_range"}B= $self->is_in_range($node->{"tree_range"}, $pos)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | and $self->is_in_range($node->{tree_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | # Inside a leaf node, e.g. the bare value of a=y. GH-277 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 5 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | # No yatt elements are under the position. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | 1 | splice @$tree, $ix, 0, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 1 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | 1 | $current; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 98 | ▶ | sub lsearch_node_pos { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lsearch_node_pos: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 98 | (my MY $self, my Position $pos, my $tree) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 98 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 98 | foreach my AltNode $node (@$tree) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 210 | ▶ | unless (defined $node->{tree_range}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 0 | Carp::confess "BUG: tree_range is empty. i=$i, tree=" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | . terse_dump($tree); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 210 | ▶ | if ($self->compare_position($self->range_end($node->{tree_range}), $pos) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | 97 | return $i; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 113 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | # Point outside of the tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 1 | return scalar @$tree; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | 5 | ▶ | sub range_start { (my MY $self, my Range $range) = @_; $range->{start}; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 210 | ▶ | sub range_end { (my MY $self, my Range $range) = @_; $range->{end}; } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 183 | ▶ | sub is_in_range { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_range: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 183 | (my MY $self, my Range $range, my Position $pos) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | $self->compare_position($range->{start}, $pos) <= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 183 | ▶ | && $self->compare_position($range->{end}, $pos) >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 571 | ▶ | sub compare_position { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_position: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 571 | (my MY $self, my Position $leftPos, my Position $rightPos) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | $leftPos->{line} <=> $rightPos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | 571 | ▶ | || $leftPos->{character} <=> $rightPos->{character}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | ▶ | sub dump_part_decllist { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_part_decllist: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table0%0/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | 0 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | $part->{_decllist} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | 0 | ▶ | sub dump_part_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_part_tree: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table0%0/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | 0 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | ▶ | unless (UNIVERSAL::isa($part, 'YATT::Lite::Core::Widget')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | Carp::croak "part $part->{kind} $part->{name} is not a widget"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | 0 | $core->ensure_parsed($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | 0 | my Widget $widget = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | $widget->{_tree} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | 57 | ▶ | sub dump_tokens_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_tokens_at_file_position: called CC=8 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 57 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | 57 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | 57 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 57 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | 57 | ▶ | return unless defined $tmpl->{nlines}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 57 | ▶ | unless ($line <= $tmpl->{nlines} - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | # warn? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | # my $yatt = $self->find_yatt_for_template($fileName); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 56 | $core->ensure_parsed($part); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 56 | ▶ | $part->{endln} //= $tmpl->{nlines}; # XXX: | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$part->{"endln"} //= $tmpl->{"nlines"}
MC/DC0%0/2
$part->{"endln"} //= $tmpl->{"nlines"}
$part->{"endln"}
$tmpl->{"nlines"}
Truth table33%1/3
A //= B
A= $part->{"endln"}B= $tmpl->{"nlines"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | 56 | my $declkind = [$part->{namespace}, $part->{kind}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | 56 | ▶ | if ($line < $part->{bodyln} - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | # At declaration | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | [decllist => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | , $self->part_decl_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | , $self->alttree($tmpl, $part->{_decllist}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | } elsif (UNIVERSAL::isa($part, 'YATT::Lite::Core::Widget')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | # At body of widget, page, args... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 54 | my Widget $widget = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | [body => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | , $self->part_body_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | , $self->alttree($tmpl, $widget->{_tree}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 54 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | # At body of action, entity, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | # XXX: TODO extract tokens for host language. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | [body_string => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | , $self->part_body_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | , $part->{_toks} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | 2 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 57 | ▶ | sub part_decl_range { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_decl_range: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 57 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | 57 | my Range $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | 57 | $range->{start} = $self->make_line_position($part->{startln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | 57 | $range->{end} = $self->make_line_position($part->{bodyln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 57 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | 326 | ▶ | sub make_line_position { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_line_position: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | 326 | (my MY $self, my ($line, $character)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 326 | my Position $p = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | 326 | ▶ | $p->{character} = $character // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$character // 0
MC/DC0%0/1
$character // 0
$character
Truth table50%1/2
A
A= $character
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | 326 | $p->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | 326 | $p; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | 56 | ▶ | sub part_body_range { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_body_range: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | 56 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | 56 | my Range $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 56 | $range->{start} = $self->make_line_position($part->{bodyln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | 56 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | 56 | ▶ | my $hasLastNL = $tmpl->{string} =~ /\n\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | $range->{end} = $self->make_line_position($part->{endln} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 56 | ▶ | - ($hasLastNL ? 1 : 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 56 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 74 | ▶ | sub find_part_of_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_part_of_file_line: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 74 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | 74 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | 74 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 74 | my Part $prev; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 74 | foreach my Part $part ($tmpl->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | 145 | ▶ | last if $line < $part->{startln} - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 86 | $prev = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 74 | ▶ | wantarray ? ($prev, $tmpl, $core) : $prev; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | 83 | ▶ | sub find_template { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_template: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | 83 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 83 | my ($fn, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 83 | my $yatt = $self->find_yatt_for_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 83 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 83 | my $tmpl = $core->find_file($fn); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | # perl コードの生成を行わないと、継承が設定されないため。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 83 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 83 | $core->find_product(perl => $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 83 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 83 | ▶ | wantarray ? ($tmpl, $core) : $tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | # Forget the in-memory text (didOpen/didChange) and re-read the file from | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | # disk. apply_changes stamps mtime with the wall clock; clearing it makes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | # refresh reload unconditionally. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | 0 | ▶ | sub reload_file_from_disk { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload_file_from_disk: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | undef $tmpl->{mtime}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 0 | $tmpl->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | 138 | ▶ | sub find_yatt_for_template { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_yatt_for_template: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | 138 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | 138 | my ($fn, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | 138 | $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | 0 | ▶ | sub cmd_show_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_show_file_line: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | (my MY $self, my @desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | $self->cli_output($self->show_file_line(@desc)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | ▶ | sub show_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_file_line: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | (my MY $self, my @desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | 0 | my ($file, $line) = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | ▶ | if (@desc == 1 and ref $desc[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@desc == 1 and ref $desc[0] eq "HASH"
MC/DC0%0/2
@desc == 1 and ref $desc[0] eq "HASH"
@desc == 1
ref $desc[0] eq "HASH"
Truth table0%0/3
A and B
A= @desc == 1B= ref $desc[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | 0 | @{$desc[0]}{'file', 'line'} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | @desc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | 0 | ▶ | my $lines = $self->{_file_line_cache}{$file} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"_file_line_cache"}{$file} //= do {
open my $fh, "<:utf8", $file or Carp::croak("Can't open ${file}: $!");
chomp(my(@lines) = readline $fh);
\@lines
}
MC/DC0%0/2
$self->{"_file_line_cache"}{$file} //= do {
open my $fh, "<:utf8", $file or Carp::croak("Can't open ${file}: $!");
chomp(my(@lines) = readline $fh);
\@lines
}
$self->{"_file_line_cache"}{$file}
do {
open my $fh, "<:utf8", $file or Carp::croak("Can't open ${file}: $!");
chomp(my(@lines) = readline $fh);
\@lines
}
Truth table0%0/3
A //= B
A= $self->{"_file_line_cache"}{$file}B= do {
open my $fh, "<:utf8", $file or Carp::croak("Can't open ${file}: $!");
chomp(my(@lines) = readline $fh);
\@lines
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | ▶ | open my $fh, "<:utf8", $file or Carp::croak "Can't open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | 0 | chomp(my @lines = <$fh>); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | unless (defined $line) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 0 | Carp::croak "line is undef!"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | 0 | [@desc, $lines->[$line - $self->{line_base}]]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | 5 | ▶ | sub find_entity_from { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_entity_from: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | 5 | (my MY $self, my ($tmplOrFile, $entityName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | 5 | ▶ | my ($tmpl) = ref $tmplOrFile ? $tmplOrFile : $self->find_template($tmplOrFile); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | 5 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | 5 | ▶ | $entns->can("entity_$entityName") | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 5 | +{@{$self->describe_entns_entity($entns, $entityName)}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | 12 | *cmd_list_entity = *cmd_list_entities;*cmd_list_entity = *cmd_list_entities; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | ▶ | sub cmd_list_entities { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_entities: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | my $nameRe = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | 0 | ▶ | if (my $nameGlob = shift @args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | 0 | Text::Glob::glob_to_regex($nameGlob); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | 0 | ▶ | my $emit_entities_in_entns; $emit_entities_in_entns = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | 0 | my ($entns, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | my $symtab = symtab($entns); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | my @methods = do { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | 0 | ▶ | if ($nameRe) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | sort grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | my $entry = $symtab->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | ▶ | if (ref \$entry eq 'GLOB' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
ref \$entry eq "GLOB" and *{$entry;}{"CODE"} and (my $meth = $_) =~ s/^entity_//
ref \$entry eq "GLOB" and *{$entry;}{"CODE"}
MC/DC0%0/2
ref \$entry eq "GLOB" and *{$entry;}{"CODE"} and (my $meth = $_) =~ s/^entity_//
ref \$entry eq "GLOB"
(my $meth = $_) =~ s/^entity_//
Truth table0%0/3
A and B
A= ref \$entry eq "GLOB"B= (my $meth = $_) =~ s/^entity_//
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | 0 | and *{$entry}{CODE} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | and (my $meth = $_) =~ s/^entity_//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | 0 | $meth =~ $nameRe; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | } keys %$symtab; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | 0 | ▶ | sort grep {/^entity_/ and *{$symtab->{$_}}{CODE}} keys %$symtab; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
/^entity_/ && *{$symtab->{$_};}{'CODE'}
MC/DC0%0/1
/^entity_/ && *{$symtab->{$_};}{'CODE'}
/^entity_/
Truth table0%0/2
A
A= /^entity_/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | 0 | foreach my $meth (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | 0 | (my $entityName = $meth) =~ s/^entity_//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 0 | my @result = @{$self->describe_entns_entity($entns, $entityName, path => $path)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | $self->cli_output( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 0 | ▶ | $self->{detail} ? [[+{@result}]] : [\@result] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | my @superNS; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | walk_vfs_folders( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | 0 | ▶ | dir => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | 0 | my ($dir, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | 0 | my $entns = $yatt->EntNS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | 0 | ▶ | return if $seen{$entns}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | 0 | push @superNS, grep {not $seen{$_}++} $dir->get_linear_isa_of_entns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 0 | ▶ | file => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | 0 | my ($tmpl, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | 0 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | foreach my $part ($tmpl->list_parts(YATT::Lite::Core->Entity)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | 0 | my @result = (name => $part->cget('name'), file => $tmpl->cget('path') | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | , line => $part->cget('startln'), entns => $entns); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | $self->cli_output( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | ▶ | $self->{detail} ? +{@result} : \@result | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | 0 | push @superNS, grep {not $seen{$_}++} $tmpl->get_linear_isa_of_entns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | 0 | foreach my $superNS (@superNS) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | 0 | my $path = YATT::Lite::Util::try_invoke($superNS, 'filename'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 0 | $emit_entities_in_entns->($superNS, $path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | 5 | ▶ | sub describe_entns_entity { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entns_entity: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 5 | (my MY $self, my ($entns, $entityName, %opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | 5 | my $vfs_item = $self->{_SITE}->get_yatt_by_entns($entns); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | 5 | my $entity; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | my $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | 5 | ▶ | if ($vfs_item | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$vfs_item and $sub = $vfs_item->can("get_type_item") and $entity = &$sub($vfs_item, "entity", $entityName)
$vfs_item and $sub = $vfs_item->can("get_type_item")
MC/DC33%1/3
$vfs_item and $sub = $vfs_item->can("get_type_item") and $entity = &$sub($vfs_item, "entity", $entityName)
$vfs_item
$sub = $vfs_item->can("get_type_item")
$entity = &$sub($vfs_item, "entity", $entityName)
Truth table50%2/4
A and B and C
A= $vfs_itemB= $sub = $vfs_item->can("get_type_item")C= $entity = &$sub($vfs_item, "entity", $entityName)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | and $sub = $vfs_item->can("get_type_item") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | and $entity = $sub->($vfs_item, entity => $entityName)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | [name => $entityName, entns => $entns | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | 4 | , file => $entity->{folder}{path}, line => $entity->{startln}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 1 | require Sub::Identify; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | 1 | my $entSub = $entns->can("entity_$entityName"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 1 | my ($file, $line) = Sub::Identify::get_code_location($entSub); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | [name => $entityName, entns => $entns | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | 1 | ▶ | , file => $file // $opts{path}, line => $line]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$file // $opts{"path"}
MC/DC0%0/2
$file // $opts{"path"}
$file
$opts{"path"}
Truth table33%1/3
A // B
A= $fileB= $opts{"path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | 0 | ▶ | sub cmd_list_vfs_folders { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_vfs_folders: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | walk_vfs_folders( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | 0 | ▶ | dir => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | 0 | my ($dir, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | # print join("\t", dir => $yatt->cget('dir'), $yatt->EntNS), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | 0 | my @result = (kind => 'dir', path => $dir->cget('path'), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | entns => $dir->cget('entns')); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | 0 | $self->cli_output(\@result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | 0 | ▶ | file => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | 0 | my ($tmpl, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | 0 | my @result = (kind => 'dir', path => $tmpl->cget('path'), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | entns => $tmpl->cget('entns')); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | 0 | $self->cli_output(\@result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | 0 | ▶ | sub cmd_list_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_widgets: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | 0 | $opts{kind} = ['widget', 'page']; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | 0 | $self->cmd_list_parts($widgetNameGlob, \%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | 0 | ▶ | sub cmd_list_actions { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_actions: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | 0 | $opts{kind} = ['action']; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | 0 | $self->cmd_list_parts($widgetNameGlob, \%opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | 0 | ▶ | sub cmd_list_parts { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_parts: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | 0 | my $onlyKind = delete $opts{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | walk( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | ($widgetNameGlob ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | (name_match => Text::Glob::glob_to_regex($widgetNameGlob)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | 0 | ▶ | widget => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | my ($found) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | 0 | my Part $widget = delete $found->{part}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | 0 | ▶ | if ($onlyKind and not grep {$found->{kind} eq $_} lexpand($onlyKind)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$onlyKind and not grep({$found->{"kind"} eq $_;} lexpand($onlyKind))
MC/DC0%0/2
$onlyKind and not grep({$found->{"kind"} eq $_;} lexpand($onlyKind))
$onlyKind
not grep({$found->{"kind"} eq $_;} lexpand($onlyKind))
Truth table0%0/3
A and not(B)
A= $onlyKindB= not grep({$found->{"kind"} eq $_;} lexpand($onlyKind))
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | # XXX: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | 0 | my Template $tmpl = $widget->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | 0 | my $path = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | my $args = $self->{detail} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | ? [$self->list_part_args_internal($widget)] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | 0 | ▶ | : $widget->{_arg_order}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | # XXX: 残念ながら、encode_json の keyword 順を制御できていない | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | tie my %result, 'Tie::IxHash', ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | 0 | (map {$_ => $found->{$_}} sort keys %$found) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | , args => $args, path => $self->clean_path($path) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | 0 | $self->cli_output([\%result]); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | 0 | ▶ | item => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | # print "# ", $args->{_tree}->cget('path'), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | # $yatt->get_trans->list_items | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | # $yatt->get_trans->find_file('index') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | # $yatt->get_trans->find_file('index')->list_parts | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | 0 | ▶ | sub list_part_args_internal { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_part_args_internal: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | 0 | (my MY $self, my Part $part, my $nameRe) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | 0 | my @fields = YATT::Lite::VarTypes->list_field_names; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | 0 | ▶ | foreach my $argName ($part->{_arg_order} ? @{$part->{_arg_order}} : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | 0 | ▶ | next if $nameRe and not $argName =~ $nameRe; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nameRe and not $argName =~ /$nameRe/
MC/DC0%0/2
$nameRe and not $argName =~ /$nameRe/
$nameRe
not $argName =~ /$nameRe/
Truth table0%0/3
A and not(B)
A= $nameReB= not $argName =~ /$nameRe/
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | 0 | my $argObj = $part->{_arg_dict}{$argName}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | push @result, my ArgSpec $spec = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | 0 | foreach my $i (0 .. $#fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | 0 | my $val = $argObj->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | 0 | $spec->{$fields[$i]} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | # Add is_required field | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | 0 | $spec->{is_required} = $argObj->is_required; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | 0 | @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | # list_code_args [--with_body] [--type=TYPE] [--from=DIR] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | # yatt 宣言 (<!yatt:args>, <!yatt:widget> ...) で宣言された code 型の引数を、 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | # 1 引数 1 レコードで列挙する。expr 型に移すべき引数を探すため (GH-300)。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | # body は出力用であることが明らかなので、既定では出さない。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | # --output=tsv では path, line, kind, name, arg, spec の順の一行になる。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | 0 | ▶ | sub cmd_list_code_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_code_args: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | 0 | my $opts = $self->parse_opts(\@args, {}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | # コマンド固有でないもの (--output など) は全体の設定へ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | $self->configure(map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | 0 | $_ => delete $opts->{$_} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | 0 | } grep {not /^(?:from|with_body|type)\z/} keys %$opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | 0 | my @fields = qw(path line kind name arg spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | 0 | ▶ | my $as_tsv = ($self->{output} // '') eq 'tsv'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"output"} // ""
MC/DC0%0/1
$self->{"output"} // ""
$self->{"output"}
Truth table0%0/2
A
A= $self->{"output"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | 0 | foreach my $rec ($self->list_code_args(%$opts)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | 0 | ▶ | $self->cli_output([$as_tsv ? [@{$rec}{@fields}] : do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | 0 | tie my %result, 'Tie::IxHash', map {$_ => $rec->{$_}} @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | 0 | \%result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | }]); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | 3 | ▶ | sub list_code_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_code_args: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | 3 | (my MY $self, my %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | 3 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | 3 | my $withBody = delete $opts{with_body}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | 3 | ▶ | my $type = delete $opts{type} // 'code'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts{"type"} // "code"
MC/DC100%1/1
delete $opts{"type"} // "code"
delete $opts{"type"}
Truth table100%2/2
A
A= delete $opts{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | 3 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | 3 | ▶ | my $bodyName = $self->{_SITE}->cget('body_argument') // 'body'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_SITE"}->cget("body_argument") // "body"
MC/DC0%0/1
$self->{"_SITE"}->cget("body_argument") // "body"
$self->{"_SITE"}->cget("body_argument")
Truth table50%1/2
A
A= $self->{"_SITE"}->cget("body_argument")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | 3 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | walk( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | from => $self->list_target_dirs($searchFrom), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | 12 | ▶ | widget => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | 12 | my ($found) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | 12 | my Part $part = $found->{part}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | 12 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | 12 | ▶ | foreach my $argName ($part->{_arg_order} ? @{$part->{_arg_order}} : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | 30 | my $var = $part->{_arg_dict}{$argName}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | 30 | ▶ | next unless $var->type->[0] eq $type; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | # 暗黙の body には印が付き、明示した body=[code ...] には付かない | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | 17 | ▶ | next if not $withBody | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $withBody and $var->is_body_argument || $argName eq $bodyName
$var->is_body_argument or $argName eq $bodyName
MC/DC100%3/3
not $withBody and $var->is_body_argument || $argName eq $bodyName
not $withBody
$var->is_body_argument
$argName eq $bodyName
Truth table100%4/4
not(A) and B or C
A= not $withBodyB= $var->is_body_argumentC= $argName eq $bodyName
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | and ($var->is_body_argument or $argName eq $bodyName); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | push @result, +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | path => $self->clean_path($tmpl->{path}), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | line => $var->lineno // $part->{startln}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | kind => $found->{kind}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | name => $found->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | 13 | ▶ | arg => $argName, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$var->lineno // $part->{"startln"}
MC/DC0%0/2
$var->lineno // $part->{"startln"}
$var->lineno
$part->{"startln"}
Truth table66%2/3
A // B
A= $var->linenoB= $part->{"startln"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | spec => $self->arg_spec_with_nested_args($var), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | 18 | ▶ | item => sub {}, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | 3 | @result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | # spec_string と違い、[code x y] のような内側の引数も含める | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | 13 | ▶ | sub arg_spec_with_nested_args { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_spec_with_nested_args: called CC=9 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | 13 | (my MY $self, my $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | 13 | my $type = join(":", @{$var->type}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | 13 | ▶ | my $widget = $var->can('widget') && $var->widget; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$var->can('widget') && $var->widget
MC/DC50%1/2
$var->can('widget') && $var->widget
$var->can('widget')
$var->widget
Truth table66%2/3
A && B
A= $var->can('widget')B= $var->widget
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | my @nested = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | 6 | my $sub = $widget->{_arg_dict}{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | 6 | ▶ | ($sub->type->[0] eq 'text' and not defined $sub->dflag) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$sub->type->[0] eq "text" and not defined $sub->dflag
$widget and $widget->{"_arg_order"}
MC/DC0%0/2
$sub->type->[0] eq "text" and not defined $sub->dflag
$sub->type->[0] eq "text"
not defined $sub->dflag
MC/DC100%2/2
$widget and $widget->{"_arg_order"}
$widget
$widget->{"_arg_order"}
Truth table33%1/3
A and not(B)
A= $sub->type->[0] eq "text"B= not defined $sub->dflag
Truth table100%3/3
A and B
A= $widgetB= $widget->{"_arg_order"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | ? $_ : "$_=".$self->arg_spec_with_nested_args($sub); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | 13 | } $widget && $widget->{_arg_order} ? @{$widget->{_arg_order}} : (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | 13 | ▶ | (@nested ? "[$type @nested]" : $type) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$var->default_expr // ""
MC/DC0%0/1
$var->default_expr // ""
$var->default_expr
Truth table0%0/2
A
A= $var->default_expr
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | . (defined $var->dflag ? $var->dflag . ($var->default_expr // '') : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | 3 | ▶ | sub is_in_template_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_template_dir: called CC=4 SCAR=15.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | 3 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | 3 | my Factory $factory = $self->{_SITE}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | 3 | foreach my $dir (lexpand($factory->{_tmpldirs})) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | 3 | ▶ | if (length $dir <= length $path | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $dir <= length $path and substr($dir, 0, length $path) eq $path
MC/DC0%0/2
length $dir <= length $path and substr($dir, 0, length $path) eq $path
length $dir <= length $path
substr($dir, 0, length $path) eq $path
Truth table33%1/3
A and B
A= length $dir <= length $pathB= substr($dir, 0, length $path) eq $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | and substr($dir, 0, length $path) eq $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | 3 | ▶ | sub list_target_dirs { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_target_dirs: called CC=5 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | 3 | (my MY $self, my $dirSpec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | 3 | ▶ | if ($dirSpec) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | 0 | $self->rel2abs($dirSpec) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | 3 | my $cwd = Cwd::getcwd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | 3 | ▶ | if ($self->is_in_template_dir($cwd)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | 0 | $cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | 3 | ▶ | $self->{_SITE}->cget('doc_root') // do { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_SITE"}->cget("doc_root") // do {
if (my $dir = $self->{"_SITE"}->cget("per_role_docroot")) {
[glob("$dir/[a-z]*")];
}
else {
Carp::croak("doc_root is empty!");
}
}
MC/DC0%0/2
$self->{"_SITE"}->cget("doc_root") // do {
if (my $dir = $self->{"_SITE"}->cget("per_role_docroot")) {
[glob("$dir/[a-z]*")];
}
else {
Carp::croak("doc_root is empty!");
}
}
$self->{"_SITE"}->cget("doc_root")
do {
if (my $dir = $self->{"_SITE"}->cget("per_role_docroot")) {
[glob("$dir/[a-z]*")];
}
else {
Carp::croak("doc_root is empty!");
}
}
Truth table33%1/3
A // B
A= $self->{"_SITE"}->cget("doc_root")B= do {
if (my $dir = $self->{"_SITE"}->cget("per_role_docroot")) {
[glob("$dir/[a-z]*")];
}
else {
Carp::croak("doc_root is empty!");
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | 0 | ▶ | if (my $dir = $self->{_SITE}->cget('per_role_docroot')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | 0 | [glob("$dir/[a-z]*")]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | 0 | Carp::croak "doc_root is empty!" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | 12 | ▶ | MY->run(\@ARGV) unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||