| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package YATT::Lite::Inspector; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use File::AddInc; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | 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 | [emit_absolute_path => doc => "emit absolute path instead of \$app_root-relative"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | [site_class => doc => "class name for SiteApp (to load app.psgi)", default => "YATT::Lite::WebMVC0::SiteApp"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | [ignore_symlink => doc => "ignore symlinked templates"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | [detail => doc => "show argument details"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | [line_base => default => 1], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | [debug_changes_dir => doc => "(LSP debugging only)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | , default => "var/debug_yatt_ls"], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # qw/debug/, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | ▶ | use MOP4Import::Util qw/lexpand symtab terse_dump globref isa_array/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | use MOP4Import::Types | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | Zipper => [[fields => qw/array index path defs/]] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | , SymbolInfo => [[fields => qw/kind name filename range refpos/] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | , [subtypes => | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | , VarInfo => [[fields => qw/type detail/]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | , EntityInfo => [[fields => qw/name entns file line/]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | , LintResult => [[fields => qw/type is_success | ||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | info | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | message | ||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | file diagnostics/]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 6 | ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | use parent qw/File::Spec/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6 | ▶ | use URI::file; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 6 | ▶ | use Text::Glob; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | use Plack::Util; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 6 | ▶ | use File::stat; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 6 | ▶ | use File::Path qw(make_path); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | ▶ | use File::Slurp qw(write_file); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 6 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | ▶ | use YATT::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | use YATT::Lite::Factory; sub Factory () {'YATT::Lite::Factory'} | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | use YATT::Lite::LRXML; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | use YATT::Lite::Core qw/Part Widget Template/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | ▶ | use YATT::Lite::CGen::Perl; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | ▶ | use YATT::Lite::VFS qw/Folder/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | use MOP4Import::Types | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 6 | ▶ | ArgSpec => [ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | [fields => | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | YATT::Lite::VarTypes->list_field_names, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'is_required', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 6 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 6 | ▶ | use YATT::Lite::LRXML::AltTree qw/column_of_source_pos AltNode/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | ▶ | use YATT::Lite::Walker qw/walk walk_vfs_folders/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | use YATT::Lite::LanguageServer::Protocol | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | ▶ | qw/Position Range MarkupContent | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Location | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | Diagnostic | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | TextDocumentContentChangeEvent | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | DocumentSymbol | ||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | CompletionItem | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | / | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | , qr/^DiagnosticSeverity__/ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | , qr/^SymbolKind__/ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | , qr/^InsertTextFormat__/ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 6 | ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 12 | ▶ | sub after_configure_default { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_configure_default: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 12 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 12 | $self->SUPER::after_configure_default; | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 12 | $self->{_SITE} = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # Site->load caches per factory script, so multiple Inspectors can | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # coexist in one process. Bare template dirs (no app.psgi) get a | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # default site instead of dying. GH-269 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 12 | my $class = Plack::Util::load_class($self->{site_class}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $class->load_or_default(dir => $self->{dir} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 12 | , class => $self->{site_class}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 12 | $self->{_app_root} = $self->{_SITE}->cget('app_root'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 12 | $self->debug_log("Initialized"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub cmd_ctags_symbols { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_ctags_symbols: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my ($dir) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $cwdOrFileList = $self->list_target_dirs($dir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | walk( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | widget => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my Part $widget = $args->{part}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my Template $tmpl = $widget->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $path = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->emit_ctags($args->{kind}, $args->{name}, $path, $widget->{startln}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | item => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $path = $args->{_tree}->cget('path'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my ($kind, $name) = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if (-l $path) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | (symlink => readlink($path)) | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | (file => $self->clean_path($path)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->emit_ctags($kind => $name, $path, 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub clean_path { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clean_path: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if (not $self->{emit_absolute_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $path =~ s,^$self->{_app_root}/*,,; | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # Same format with "ctags -x --_xformat=%{input}:%n:1:%K!%N" (I hope). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub emit_ctags { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit_ctags: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | (my MY $self, my ($kind, $name, $fileName, $lineNo, $colNo)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # XXX: symbolKind mapping. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | , $lineNo, $colNo // 1, $kind, $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub load_string_into_file { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_string_into_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | (my MY $self, my ($fileName, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $core->get_parser->load_string_into($tmpl, $text, all => 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $result //= +{}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $self->yatterror2lintresult($_, $result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub apply_changes { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_changes: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | (my MY $self, my ($fileName, @changes)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my Template $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | my $lines = [defined $tmpl->{string} && $tmpl->{string} ne "" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 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 ""
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | foreach my TextDocumentContentChangeEvent $change (@changes) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $lines = $self->apply_change_to_lines($lines, $change); | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $tmpl->{mtime} = time; | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $changed = join("\n", @$lines); | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ($self->debug_changes_dir_exists) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $destFn = $self->debug_changes_write_file($fileName, $changed); | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | print STDERR "# Wrote: $destFn\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $core->get_parser->load_string_into($tmpl, $changed, all => 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $tmpl->{string} = $changed; | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $result //= +{}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->yatterror2lintresult($_, $result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | $result->{info}{from} = ["line: ", __LINE__]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if (not $result) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my LintResult $res = $self->lint($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | $result = $res unless $res->{is_success}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ($changed, $result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub head_as_json_array { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head_as_json_array: not called CC=4 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $limit = 10; | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($_[0] =~ /^-(\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $limit = $1; shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | ▶ | use open qw(:std :locale); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | local @ARGV = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | while (<>) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | push @result, $_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | last if --$limit <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | \@result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub debug_changes_dir_exists { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_changes_dir_exists: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | defined $self->{dir} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | && | ||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | && | ||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | -d "$self->{dir}/$self->{debug_changes_dir}"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | sub debug_changes_write_file { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_changes_write_file: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | (my MY $self, my ($fileName, $changed)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $debugDir = "$self->{dir}/$self->{debug_changes_dir}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | substr($fileName, 0, length $self->{dir}) = ""; | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $destFn = "$debugDir/$fileName." . Time::HiRes::time; | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $destDir = File::Basename::dirname($destFn); | |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | unless (-d $destDir) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | make_path($destDir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | write_file($destFn, +{binmode => ':utf8'}, $changed); | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # 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}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # [["fxxoooo","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # 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}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # [["fxxooooo","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # 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}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # [["fxx","bar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # 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}}}' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # [["fxxar","baz"]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub cmd_apply_all_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_apply_all_change_to_lines: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | (my MY $self, my $linesOrFileName, my $changeList) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $lines = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (ref $linesOrFileName) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $linesOrFileName | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | [split /\r?\n/, YATT::Lite::Util::read_file($linesOrFileName)] | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $result = $self->apply_all_change_to_lines($lines, $changeList); | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | print $_, "\n" for @$result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sub apply_all_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_all_change_to_lines: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | (my MY $self, my $lines, my $changeList) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | foreach my TextDocumentContentChangeEvent $change (@$changeList) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $lines = $self->apply_change_to_lines($lines, $change); | |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $lines; | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | sub apply_change_to_lines { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_change_to_lines: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | (my MY $self, my $lines, my TextDocumentContentChangeEvent $change) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my Range $from = $change->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | unless ($from) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # Full document sync: the whole text replaces the document. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return [$text ne '' ? split(/\n/, $text, -1) : ('')]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my Position $start = $from->{start}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my Position $end = $from->{end}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my @pre = @{$lines}[0 .. $start->{line}-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my @post = @{$lines}[$end->{line}+1 .. $#$lines]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ($start->{line} == $end->{line}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my @edited = $lines->[$start->{line}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | substr($edited[0] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | , $start->{character}, $end->{character} - $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | , $change->{text}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | @edited = split /\n/, $edited[0], -1 if $edited[0] ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | Carp::croak "failed to apply changes: " | ||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | . terse_dump([original => $lines->[$start->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | , start => $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | , len => $end->{character} - $start->{character} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | , changed => $change->{text}]). ": $_"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | [@pre, @edited, @post]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my ($pre_edit, $post_edit); | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $pre_edit = substr($lines->[$start->{line}], 0, $start->{character}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $post_edit = substr($lines->[$end->{line}], $end->{character}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | Carp::croak "failed to apply multiline changes: " | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | . terse_dump([pre => [original => $lines->[$start->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | , start => $start->{character}] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | , post => [original => $lines->[$end->{line}] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | , end => $end->{character}] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | , changed => $change->{text}]). ": $_"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $edited = $pre_edit.$change->{text}.$post_edit; | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my @edited = $edited ne '' ? split(/\n/, $edited, -1) : $edited; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | [@pre, @edited, @post]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub append_file { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | (my MY $self, my ($fileName, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my Range $ending = $self->file_ending_range($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $self->apply_changes($fileName, +{ | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | range => $ending, rangeLength => 0, text => $text | ||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | sub file_ending_range { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_ending_range: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | (my MY $self, my ($fileNameOrTemplate)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my Template $tmpl = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if (ref $fileNameOrTemplate) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | unless ($fileNameOrTemplate->isa(Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | Carp::croak "Invalid argument type: ". ref($fileNameOrTemplate) | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $fileNameOrTemplate | ||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $self->find_template($fileNameOrTemplate); | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my ($lineNo, $colNo) = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | my $lines = [defined $tmpl->{string} && $tmpl->{string} ne "" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 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 ""
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $lastLine = $lines->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ($#$lines, length($lastLine)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my Position $start = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $start->{line} = $lineNo; $start->{character} = $colNo; | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my Position $end = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $end->{line} = $lineNo; $end->{character} = $colNo; | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my Range $range = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $range->{start} = $start; $range->{end} = $end; | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 12 | ▶ | sub lint : method { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lint: called CC=1 SCAR=0.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 12 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 12 | my ($baseName, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 12 | my LintResult $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | my $mtime; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 12 | my $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 12 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 12 | ▶ | if (-r $fileName) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 12 | $mtime = stat($fileName)->mtime; | |||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | $self->{_SITE}->cf_let([ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | error_handler => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | (my $type, my YATT::Lite::Error $err) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $result->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $self->yatterror2lintresult($err, $result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | die $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 12 | ▶ | ], sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 12 | my $yatt = $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # $yatt->fconfigure_encoding(\*STDOUT, \*STDERR); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # get_trans is not ok. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 12 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 12 | $tmpl = $core->find_file($baseName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 12 | $tmpl->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 12 | my $pkg = $core->find_product(perl => $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 4 | $result->{is_success} = JSON()->true; | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 4 | $result->{info}{mtime} = [$mtime, $tmpl->{mtime}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 12 | }); | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 8 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 8 | ▶ | unless ($result) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 8 | my $backtrace; | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 8 | ▶ | if (not ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $self->strerror2lintresult($tmpl, $_, $result //= {}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } elsif (UNIVERSAL::isa($_, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 8 | ▶ | $self->yatterror2lintresult($_, $result //= +{}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result //= {}
MC/DC0%0/1
$result //= {}
$result
Truth table50%1/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 8 | $backtrace = $_->{backtrace}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $result->{message} = $_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $result->{info}{from} = ["line: ", __LINE__]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 8 | ▶ | $result->{info}{mtime} = [$mtime, $tmpl->{mtime}] if defined $mtime; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 8 | ▶ | $result->{info}{backtrace} = $self->backtrace2list($backtrace) if $backtrace; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 12 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 8 | ▶ | sub yatterror2lintresult { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
yatterror2lintresult: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 8 | (my MY $self, my YATT::Lite::Error $err, my LintResult $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 6 | ▶ | use YATT::Lite::Util::AllowRedundantSprintf; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 8 | $result->{info}{from} = 'yatterror2lintresult'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | $result->{file} = $err->{tmpl_file}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 8 | $result->{diagnostics} = my Diagnostic $diag = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 8 | $diag->{severity} = DiagnosticSeverity__Error; | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 8 | ▶ | $diag->{message} = $err->{reason} // do { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/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 table33%1/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
}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 8 | my $str; | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 8 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 8 | $str = sprintf($err->{format}, @{$err->{args}}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $str = terse_dump([$_, $err->{format}, @{$err->{args}}]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 8 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 8 | $diag->{range} = $self->make_line_range($err->{tmpl_line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 8 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub strerror2lintresult { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strerror2lintresult: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | (my MY $self, my Template $tmpl, my $errStr, my LintResult $result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $result->{info}{from} = 'strerror2lintresult'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $result->{file} = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $result->{diagnostics} = my Diagnostic $diag = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $diag->{severity} = DiagnosticSeverity__Error; | |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # Keep the whole message (perl may report several errors at once); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # the range comes from the first reported line. GH-269 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $errStr =~ s/\n+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $diag->{message} = $errStr; | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if ($errStr =~ / line (\d+)[,\.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # make_line_range takes a 0-based line (cf. yatterror2lintresult). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $diag->{range} = $self->make_line_range($1 - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 8 | ▶ | sub backtrace2list { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
backtrace2list: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 8 | (my MY $self, my $trace) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 8 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 8 | ▶ | while (my $frame = $trace->next_frame) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | push @list, +{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 188 | map {$_ => $frame->$_()} | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | package filename line subroutine | ||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 8 | \@list; | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # $lineno is 0-based (LSP). Callers holding 1-based lines (Part startln, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # Sub::Identify) must subtract 1. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 34 | ▶ | sub make_line_range { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_line_range: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 34 | (my MY $self, my $lineno) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 34 | my Range $range = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 34 | $range->{start} = $self->make_line_position($lineno); | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 34 | $range->{end} = $self->make_line_position($lineno+1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 34 | $range | |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 54 | ▶ | sub alttree { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alttree: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 54 | (my MY $self, my ($tmpl, $tree)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 54 | my $converter = YATT::Lite::LRXML::AltTree->new( | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | string => $tmpl->cget('string'), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | with_source => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 54 | [$converter->convert_tree($tree)]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 19 | ▶ | sub lookup_symbol_definition { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 19 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 19 | ▶ | unless (defined $sym->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | Carp::croak "kind in SymbolInfo is empty! " | |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | . terse_dump($sym); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 19 | ▶ | my $sub = $self->can("lookup_symbol_definition_of__$sym->{kind}") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 19 | $sub->($self, $sym, $cursor); | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3 | ▶ | sub lookup_symbol_definition_of__ELEMENT { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ELEMENT: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 3 | my Position $pos = $sym->{refpos}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 3 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # assert($node); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 3 | my $wname = join(":", lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # XXX: yatt:if, yatt:foreach, ... macro | ||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # XXX: calllable_vars like <yatt:body/> | ||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | $node->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 3 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 3 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 3 | $loc->{uri} = $self->filename2uri($self->part_filename($widget)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | $loc->{range} = $self->part_decl_range($widget); | |||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 3 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 6 | ▶ | sub lookup_symbol_definition_of__var { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__var: called CC=4 SCAR=18.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 6 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 6 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 6 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # args and <yatt:my> vars are always defined in the file of the cursor. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 6 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 6 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 6 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if (my EntityInfo $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $loc->{uri} = $self->filename2uri($entFunc->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # {line} is 1-based (Part startln / Sub::Identify). GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $loc->{range} = $self->make_line_range($entFunc->{line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 2 | ▶ | sub lookup_symbol_definition_of__call { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__call: called CC=4 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # args and <yatt:my> vars are always defined in the file of the cursor. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | ▶ | if (my EntityInfo $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | $loc->{uri} = $self->filename2uri($entFunc->{file}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 600 | # {line} is 1-based (Part startln / Sub::Identify). GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 2 | $loc->{range} = $self->make_line_range($entFunc->{line} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # Attributes at a widget call site. GH-277 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # (see CGen::Perl::gen_putargs and passThruVar) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # <yatt:foo x/> passes the variable x in scope to formal arg x | ||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # (a flag when there is no such variable) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # <yatt:foo a=y/> passes the variable y in scope to formal arg a | ||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # <yatt:foo b="..."/> b is a formal arg; entities in the value are | ||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # resolved through the entpath subtree as before | ||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # <:yatt:d>...</:yatt:d> d is a formal arg | ||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 2 | ▶ | sub lookup_symbol_definition_of__ATTRIBUTE { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATTRIBUTE: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | // $self->formal_arg_location($sym, $cursor, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 3 | ▶ | sub lookup_symbol_definition_of__ATT_BARENAME { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_BARENAME: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 3 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | and $self->is_in_range($node->{value_range}, $sym->{refpos})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 2 | return $self->variable_location($sym, $cursor, $node->{value}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | $self->formal_arg_location($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 2 | ▶ | sub lookup_symbol_definition_of__ATT_TEXT { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_TEXT: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | $self->formal_arg_location($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | ▶ | sub lookup_symbol_definition_of__ATT_NESTED { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_symbol_definition_of__ATT_NESTED: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 1 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # Only attribute elements (<:yatt:d>) have a symbol_range. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | ▶ | return unless $node->{symbol_range}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | $self->formal_arg_location($sym, $cursor, $path[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # The ELEMENT node which owns the attribute at $cursor, if any. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 7 | ▶ | sub parent_element_of_cursor { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent_element_of_cursor: called CC=5 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 7 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 7 | ▶ | my Zipper $parent = $cursor->{path} or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 7 | ▶ | my AltNode $elem = $parent->{array}[$parent->{index}] or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 7 | $elem; | |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | # ($widget, $var, $range) of the formal argument $argName of the widget | ||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # called by the element which owns the attribute at $cursor, or (). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 7 | ▶ | sub locate_formal_arg { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_formal_arg: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 7 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 7 | ▶ | my AltNode $elem = $self->parent_element_of_cursor($cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 7 | my Position $pos = $sym->{refpos}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | $elem->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 7 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 6 | ▶ | return unless UNIVERSAL::isa($widget, 'YATT::Lite::Core::Widget'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 6 | ▶ | my $arg = $widget->{_arg_dict}{$argName} or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | // $self->make_line_range(($arg->lineno // 1) - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 6 | ($widget, $arg, $range); | |||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 5 | ▶ | sub formal_arg_location { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formal_arg_location: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 5 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 5 | ▶ | my ($widget, $arg, $range) = $self->locate_formal_arg($sym, $cursor, $argName) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 4 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 4 | $loc->{uri} = $self->filename2uri($self->part_filename($widget)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | $loc->{range} = $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 4 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # Location of the variable $name visible at $cursor (args, <yatt:my>). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 4 | ▶ | sub variable_location { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
variable_location: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 4 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 4 | my SymbolInfo $varSym = +{%$sym}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 4 | $varSym->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 4 | ▶ | my VarInfo $var = $self->locate_entity_var($varSym, $cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 3 | my Location $loc = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 3 | $loc->{range} = $var->{range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 3 | $loc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 2 | ▶ | sub describe_symbol_of_ATTRIBUTE { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATTRIBUTE: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | // $self->describe_formal_arg($sym, $cursor, $name); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2 | ▶ | sub describe_symbol_of_ATT_BARENAME { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_BARENAME: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 2 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | and $self->is_in_range($node->{value_range}, $sym->{refpos})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 1 | return $self->describe_variable($sym, $cursor, $node->{value}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 1 | $self->describe_formal_arg($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | sub describe_symbol_of_ATT_TEXT { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_TEXT: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | $self->describe_formal_arg($sym, $cursor, $name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | sub describe_symbol_of_ATT_NESTED { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ATT_NESTED: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | return unless $node->{symbol_range}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my @path = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $self->describe_formal_arg($sym, $cursor, $path[-1]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 3 | ▶ | sub describe_variable { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_variable: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 3 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 3 | my SymbolInfo $varSym = +{%$sym}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 3 | $varSym->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 3 | ▶ | my VarInfo $var = $self->locate_entity_var($varSym, $cursor) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | $self->describe_entity_var($varSym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 2 | ▶ | sub describe_formal_arg { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_formal_arg: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $argName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 2 | ▶ | my ($widget, $arg) = $self->locate_formal_arg($sym, $cursor, $argName) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 2 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 2 | $md->{value} = $self->md_quote_code_as( | |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | yatt => "argument $argName of <" . $widget->callsite_name . ">: " | ||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | . $arg->spec_string | ||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | $md; | |||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 18 | ▶ | sub filename2uri { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filename2uri: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 18 | (my MY $self, my $fn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 18 | URI::file->new_abs($fn)->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 31 | ▶ | sub part_filename { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_filename: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 31 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 31 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 31 | $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 4 | ▶ | sub describe_symbol { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 4 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 4 | ▶ | unless (defined $sym->{kind}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | Carp::croak "kind in SymbolInfo is empty! " | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | . terse_dump($sym); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 4 | ▶ | my $resolver = $self->can("describe_symbol_of_$sym->{kind}") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 4 | $resolver->($self, $sym, $cursor); | |||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | sub describe_symbol_of_ELEMENT { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_ELEMENT: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | my AltNode $node = $cursor->{array}[$cursor->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | # assert($node); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | my Position $pos = $self->range_start($sym->{range}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | my $wname = join(":", lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # XXX: builtin macros like yatt:if, yatt:foreach, ... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # XXX: calllable_vars like <yatt:body/> | ||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | my Part $widget = $self->lookup_widget_from( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | $node->{path}, $sym->{filename}, $pos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $md->{value} = $self->widget_signature_md($widget, 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | $md; | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | sub describe_symbol_of_call { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_call: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor, 'code')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | return $self->describe_entity_var($sym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | if (my $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | return $self->describe_entity_function($sym, $entFunc); | |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | sub describe_symbol_of_var { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_symbol_of_var: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | if (my VarInfo $var = $self->locate_entity_var($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | return $self->describe_entity_var($sym, $var); | |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | if (my $entFunc = $self->locate_entity_function($sym, $cursor)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | return $self->describe_entity_function($sym, $entFunc); | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 2 | ▶ | sub describe_entity_var { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entity_var: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 2 | (my MY $self, my SymbolInfo $sym, my VarInfo $var) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 2 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 2 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | my $text = "$var->{kind} $var->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | $text .= ": $var->{type}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | ▶ | $text .= "=$var->{detail}" if $var->{detail}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 2 | $md->{value} = $self->md_quote_code_as(yatt => $text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 2 | return $md; | |||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | sub describe_entity_function { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entity_function: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | (my MY $self, my SymbolInfo $sym, my EntityInfo $entFunc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my MarkupContent $md = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | $md->{kind} = 'markdown'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my $text = "function $sym->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $md->{value} = $self->md_quote_code_as(yatt => $text); | |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | return $md; | |||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 15 | ▶ | sub locate_entity_var { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_entity_var: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 15 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor, my $ofType) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 15 | ▶ | for (my Zipper $c = $cursor; $c; $c = $c->{path}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 32 | ▶ | if (my $defs = $c->{defs}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 15 | ▶ | if (my VarInfo $var = $defs->{$sym->{name}}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 11 | ▶ | next if defined $ofType and $var->{type} ne $ofType; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ofType and $var->{"type"} ne $ofType
MC/DC0%0/2
defined $ofType and $var->{"type"} ne $ofType
defined $ofType
$var->{"type"} ne $ofType
Truth table33%1/3
A and B
A= defined $ofTypeB= $var->{"type"} ne $ofType
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 11 | return $var; | |||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 2 | ▶ | sub locate_entity_function { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_entity_function: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 2 | (my MY $self, my SymbolInfo $sym, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 2 | my ($tmpl, $core) = $self->find_template($sym->{filename}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 2 | $self->find_entity_from($tmpl, $sym->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 4 | ▶ | sub md_quote_code_as { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
md_quote_code_as: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 4 | (my MY $self, my ($langId, $text)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 4 | my $pre = q{```}.$langId."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 4 | $text =~ s/\n*\z/\n/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 4 | $pre.$text.q{```}."\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | sub widget_signature_md { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
widget_signature_md: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | (my MY $self, my Widget $widget, my $detail) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my $wname = $widget->callsite_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 887 | my $args = join("", map { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | my $var = $widget->{_arg_dict}{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | " ".join("=", $_, q{"}.$var->spec_string.q{"}).($detail ? "\n" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | } @{$widget->{_arg_order}}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | if ($detail) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | $self->md_quote_code_as(yatt => "($widget->{kind}) <$wname$args/>"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | $args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | sub list_parts_in { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_parts_in: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | foreach my Part $part ($tmpl->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | push @result, my DocumentSymbol $sym = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | $sym->{name} = "$part->{kind} $part->{name}"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | ▶ | $sym->{kind} = $part->isa(Widget) ? SymbolKind__Constructor | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | : SymbolKind__Method; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | if ($part->isa(Widget)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | $sym->{detail} = $self->widget_signature_md($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $sym->{range} = $self->part_decl_range($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | $sym->{selectionRange} = $self->part_decl_range($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 10 | ▶ | sub lookup_widget_from { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup_widget_from: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 10 | (my MY $self, my ($wpath, $fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 10 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 10 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 10 | $core->build_cgen_of('perl') | |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | ->with_template($tmpl, lookup_widget => lexpand($wpath)); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 27 | ▶ | sub locate_symbol_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_symbol_at_file_position: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 27 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 27 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 27 | ▶ | $column //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$column //= 0
MC/DC0%0/1
$column //= 0
$column
Truth table50%1/2
A
A= $column
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 27 | ▶ | my Zipper $cursor = $self->locate_node_at_file_position( | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | $fileName, $line, $column | ||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 24 | ▶ | my AltNode $node = $cursor->{array}[$cursor->{index}] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 23 | my SymbolInfo $info = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 23 | $info->{kind} = $node->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 23 | $info->{name} = join(":", lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 23 | $info->{range} = $node->{symbol_range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 23 | $info->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 23 | $info->{refpos} = my Position $pos = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 23 | $pos->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 23 | $pos->{character} = $column; | |||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 23 | ▶ | wantarray ? ($info, $cursor) : $info; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 13 | ▶ | sub is_debug_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debug_enabled: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 13 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 13 | ▶ | defined $self->{dir} && -e "$self->{dir}/DEBUG_YATT_LANGSERVER"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 13 | ▶ | sub debug_log { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_log: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 13 | (my MY $self, my @message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 13 | ▶ | return unless $self->is_debug_enabled; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | print STDERR "[YATT::Lite::Inspector] ", @message, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | sub get_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file_line: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | (my MY $self, my ($fileName, $lineNumber)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | my ($tmpl) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # Split template string into lines | ||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my @lines = split /\n/, $tmpl->{string}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | return $lines[$lineNumber] if $lineNumber < @lines; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | sub get_completion_items { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_completion_items: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | (my MY $self, my ($fileName, $line, $column, $triggerCharacter)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | # Get active namespaces | ||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | my @namespaces = lexpand($self->{_SITE}->cget('namespace')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 0 | ▶ | @namespaces = ('yatt') unless @namespaces; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $self->debug_log("Active namespaces: " . join(", ", @namespaces)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | # Get the current line text | ||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my $lineText = $self->get_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | return unless defined $lineText; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | $self->debug_log("Line text: '$lineText'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | # Extract the prefix before cursor position | ||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $prefix = substr($lineText, 0, $column); | |||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $self->debug_log("Prefix before cursor: '$prefix'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # Determine completion context | ||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # Create namespace pattern | ||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $ns_pattern = join('|', map { quotemeta } @namespaces); | |||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # Check for widget or entity completion | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 0 | ▶ | if ($prefix =~ /<($ns_pattern):(\w*(?::\w*)*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # Widget completion: <namespace:widgetname | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | my $widgetPath = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $self->debug_log("Widget completion detected: namespace=$namespace, path='$widgetPath'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | push @items, $self->complete_widgets($fileName, $namespace, $widgetPath); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | elsif ($prefix =~ /&($ns_pattern):(\w*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # Entity completion: &namespace:entity | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | my $entityName = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | $self->debug_log("Entity completion detected: namespace=$namespace, name='$entityName'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | push @items, $self->complete_entities($fileName, $namespace, $entityName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | elsif ($prefix =~ /<!($ns_pattern):(\w*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | # Declaration completion: <!namespace:declaration | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | my $namespace = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | ▶ | my $declName = $2 // ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$2 // ""
MC/DC0%0/1
$2 // ""
$2
Truth table0%0/2
A
A= $2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | $self->debug_log("Declaration completion detected: namespace=$namespace, name='$declName'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | push @items, $self->complete_declarations($fileName, $namespace, $declName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | $self->debug_log("No completion pattern matched"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | # TODO: Widget argument completion | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | $self->debug_log("Returning " . scalar(@items) . " completion items"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | return @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | sub complete_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | (my MY $self, my ($fileName, $namespace, $widgetPath)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | $self->debug_log("complete_widgets: widgetPath='$widgetPath'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my @path = split /:/, $widgetPath; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | $self->debug_log("Widget path parts: [" . join(", ", @path) . "], partial='$partialName'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # 1. First, add macro widgets (built-in widgets have highest priority) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | push @items, $self->complete_macro_widgets($fileName, $namespace, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | $self->debug_log("Found " . scalar(grep { $_->{detail} =~ /macro/ } @items) . " macro widgets"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | # 2. Then search for user-defined widgets | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | if (@path) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | # Complex path like foo:bar:w* | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | push @items, $self->complete_widgets_with_path($fileName, $namespace, \@path, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | # Simple completion like w* | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | push @items, $self->complete_widgets_simple($fileName, $namespace, $partialName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | # Remove duplicates while preserving order | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | my @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | foreach my $item (@items) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | next if $seen{$item->{label}}++; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | push @unique, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | return @unique; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | sub complete_entities { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entities: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | (my MY $self, my ($fileName, $namespace, $prefix, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | $self->debug_log("complete_entities: prefix='$prefix', line=$line"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | # 1. Entity macros (highest priority) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | push @items, $self->complete_entity_macros($fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | $self->debug_log("Found " . scalar(grep { $_->{detail} =~ /entity macro/ } @items) . " entity macros"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # 2. Variables (widget arguments) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | my $var_count_before = @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | push @items, $self->complete_entity_variables($fileName, $namespace, $prefix, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | my $var_count = scalar(grep { $_->{kind} == 13 } @items) - scalar(grep { $_->{kind} == 13 } @items[0..$var_count_before-1]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | $self->debug_log("Found $var_count variables"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | # 3. Entity functions | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | my $func_count_before = @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | push @items, $self->complete_entity_functions($fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | $self->debug_log("Found " . (@items - $func_count_before) . " entity functions"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | # Remove duplicates while preserving order | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | my @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | foreach my $item (@items) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | ▶ | next if $seen{$item->{label}}++; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | push @unique, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | # Sort to show variables first, then entity macros, then entity functions | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | my @sorted = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | # Variables (kind == 13) come first | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | ▶ | my $a_is_var = $a->{kind} == 13 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | ▶ | my $b_is_var = $b->{kind} == 13 ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | if ($a_is_var != $b_is_var) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | return $a_is_var <=> $b_is_var; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | # Then entity macros | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | my $a_is_macro = ($a->{detail} && $a->{detail} =~ /entity macro/) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$YATT::Lite::Inspector::a->{"detail"} and $YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
MC/DC0%0/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 table0%0/3
A and B
A= $YATT::Lite::Inspector::a->{"detail"}B= $YATT::Lite::Inspector::a->{"detail"} =~ /entity macro/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | ▶ | my $b_is_macro = ($b->{detail} && $b->{detail} =~ /entity macro/) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$YATT::Lite::Inspector::b->{"detail"} and $YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
MC/DC0%0/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 table0%0/3
A and B
A= $YATT::Lite::Inspector::b->{"detail"}B= $YATT::Lite::Inspector::b->{"detail"} =~ /entity macro/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | if ($a_is_macro != $b_is_macro) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | return $a_is_macro <=> $b_is_macro; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | # Finally sort by label | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | return $a->{label} cmp $b->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } @unique; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | $self->debug_log("Total unique entities: " . scalar(@sorted)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | return @sorted; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | ▶ | sub complete_macro_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_macro_widgets: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | # Get the code generator | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | my $cgen = $core->build_cgen_of('perl'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | # Find all macro_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | my @methods = $self->list_methods_starting_with($cgen_class, 'macro_'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | my $widget_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | $widget_name =~ s/^macro_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | next unless $widget_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | $item->{label} = $widget_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | $item->{kind} = SymbolKind__Constructor; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | $item->{detail} = "macro $namespace:$widget_name"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $item->{documentation} = "Built-in macro widget"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | ▶ | sub complete_widgets_simple { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_simple: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | # Search in current template first | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | foreach my Widget $widget ($tmpl->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | next if $widget->{name} eq ''; # Skip default widget | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | next unless $widget->{name} =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | push @items, $self->make_widget_completion_item($widget, $namespace); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | # Search in current directory and inherited directories | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | if (my Folder $folder = $tmpl->{parent}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | push @items, $self->complete_widgets_in_folder_recursive($folder, $fileName, $namespace, $prefix, $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | ▶ | sub complete_widgets_with_path { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_with_path: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | (my MY $self, my ($fileName, $namespace, $pathRef, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | my @path = @$pathRef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | # Try with namespace first, then without | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | || $core->find_part_from($tmpl, @path); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | if ($target) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | ▶ | if ($target->isa($self->Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | # Found a template file, complete widgets within it | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | foreach my Widget $widget ($target->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | next if $widget->{name} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 0 | ▶ | next unless $widget->{name} =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | foreach my CompletionItem $item ($self->make_widget_completion_item($widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | # Adjust label to include full path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | my $full_path = join(':', @path, $widget->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | my $original_label = $item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | $item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | $item->{detail} = "widget $namespace:" . $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | $item->{filterText} = $full_path; # Update filter text too | |||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | } elsif ($target->isa('YATT::Lite::VFS::Folder')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | # Found a folder, complete files/widgets within it | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | push @items, $self->complete_widgets_in_folder($target, $fileName, $namespace, $prefix, undef, \@path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | ▶ | sub complete_widgets_in_folder_recursive { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_in_folder_recursive: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | (my MY $self, my Folder $folder, my ($fileName, $namespace, $prefix, $exclude_tmpl)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | my %seen; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | # Search current folder | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | push @items, $self->complete_widgets_in_folder($folder, $fileName, $namespace, $prefix, $exclude_tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # Search in base folders (inheritance) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | my @queue = ($folder); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | while (@queue) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | my Folder $cur = shift @queue; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | ▶ | next if $seen{$cur}++; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | if (my $base = $cur->{base}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | ▶ | my @bases = ref($base) eq 'ARRAY' ? @$base : $base; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | foreach my Folder $base_folder (@bases) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | push @items, $self->complete_widgets_in_folder($base_folder, $fileName, $namespace, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | push @queue, $base_folder; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | ▶ | sub complete_widgets_in_folder { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_widgets_in_folder: not called CC=21 SCAR=61.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | (my MY $self, my Folder $folder, my ($fileName, $namespace, $prefix, $exclude_tmpl, $pathPrefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | ▶ | $pathPrefix //= []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$pathPrefix //= []
MC/DC0%0/1
$pathPrefix //= []
$pathPrefix
Truth table0%0/2
A
A= $pathPrefix
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | # Refresh folder to ensure we have latest content | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | $folder->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | # Get all parts in this folder | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | foreach my Part $part ($folder->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | ▶ | next unless $part; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | if ($part->isa($self->Template)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | my Template $tmpl = $part; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | # Extract base name without extension | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | my $base_name = $tmpl->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | ▶ | $base_name =~ s/\.\w+$// if defined $base_name; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | # Check if this matches our prefix | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 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/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # File name matches - suggest the file itself (default widget) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | ▶ | if (my $default_widget = $tmpl->{_Item}{''}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | foreach my CompletionItem $comp_item ($self->make_widget_completion_item($default_widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | ▶ | my $full_path = @$pathPrefix ? join(':', @$pathPrefix, $base_name) : $base_name; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | my $original_label = $comp_item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | $comp_item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | $comp_item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | $comp_item->{detail} = "template $namespace:$full_path (default widget)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | $comp_item->{filterText} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # Fix insertText for default widgets (which have empty name) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | if ($comp_item->{insertTextFormat} == InsertTextFormat__Snippet) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # Replace empty widget name with the actual path in snippet | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | $comp_item->{insertText} =~ s/^>/$full_path>/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | $comp_item->{insertText} =~ s/<\/\Q$namespace\E:>/<\/$namespace:$full_path>/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # Replace empty widget name in plain text | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | $comp_item->{insertText} =~ s/^\/>/$full_path\/>/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 0 | push @items, $comp_item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | # Also suggest widgets within this file | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | foreach my Widget $widget ($tmpl->widget_list) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | ▶ | next if $widget->{name} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | foreach my CompletionItem $comp_item ($self->make_widget_completion_item($widget, $namespace)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | my $full_path = @$pathPrefix | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | ? join(':', @$pathPrefix, $base_name, $widget->{name}) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | : join(':', $base_name, $widget->{name}); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my $original_label = $comp_item->{label}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | ▶ | if ($original_label =~ / \(self-closing\)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | $comp_item->{label} = $full_path . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | $comp_item->{label} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | $comp_item->{detail} = "widget $namespace:$full_path"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | $comp_item->{filterText} = $full_path; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | push @items, $comp_item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | ▶ | sub make_widget_completion_item { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_widget_completion_item: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | (my MY $self, my Widget $widget, my ($namespace)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | # We'll return multiple items for different tag styles | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | # Base item properties (shared between variants) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | my $base = { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | kind => SymbolKind__Function, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | detail => "widget $namespace:$widget->{name}", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | # Add argument info if available | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | my @args = $self->list_part_args_internal($widget); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | my $doc = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | my @snippet_params; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | my $param_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | my @argSpecs; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | foreach my ArgSpec $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my $spec = $arg->{varname}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | ▶ | $spec .= ": " . $arg->{type}->[0] if $arg->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | ▶ | $spec .= " (required)" if $arg->{is_required}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | push @argSpecs, $spec; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # Build snippet parameters for required arguments | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | $param_count++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | push @snippet_params, $arg->{varname} . '="${' . $param_count . ':' . $arg->{varname} . '}"'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | ▶ | $doc = join("\n", @argSpecs) if @argSpecs; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | # 1. Self-closing tag variant | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | my CompletionItem $item = { %$base }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | $item->{label} = $widget->{name} . " (self-closing)"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | $item->{sortText} = $widget->{name} . "_1"; # Sort after the main variant | |||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 0 | $item->{filterText} = $widget->{name}; # Filter by widget name only | |||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | ▶ | $item->{documentation} = $doc if $doc; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | if (@snippet_params) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | $item->{insertText} = $widget->{name} . ' ' . join(' ', @snippet_params) . '/>'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | $item->{insertText} = $widget->{name} . '/>'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | # 2. Open/close tag variant | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | my CompletionItem $item = { %$base }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | $item->{label} = $widget->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | $item->{sortText} = $widget->{name} . "_0"; # Sort before self-closing | |||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 0 | $item->{filterText} = $widget->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | $item->{documentation} = $doc if $doc; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | 0 | my $next_pos = $param_count + 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | ▶ | if (@snippet_params) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | $item->{insertText} = $widget->{name} . ' ' . join(' ', @snippet_params) . '>$' . $next_pos . '</' . $namespace . ':' . $widget->{name} . '>'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | $item->{insertText} = $widget->{name} . '>$1</' . $namespace . ':' . $widget->{name} . '>'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | # Return list in list context, single item in scalar context (for backward compatibility) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | wantarray ? @items : $items[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | sub list_methods_starting_with { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_methods_starting_with: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | (my MY $self, my ($class, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | my @methods; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | my $symtab = symtab($class); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | foreach my $name (keys %$symtab) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | next unless $name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | my $glob = MOP4Import::Util::globref($class, $name); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | next unless defined *{$glob}{CODE}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | push @methods, $name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | # Also check parent classes | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | foreach my $parent (@{MOP4Import::Util::isa_array($class)}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | push @methods, $self->list_methods_starting_with($parent, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | # Remove duplicates | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | grep { !$seen{$_}++ } @methods; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 0 | ▶ | sub complete_entity_macros { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_macros: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | # Get the code generator | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | my $cgen = $core->build_cgen_of('perl'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | # Find all entmacro_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | my @methods = $self->list_methods_starting_with($cgen_class, 'entmacro_'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 0 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 0 | my $entity_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 0 | $entity_name =~ s/^entmacro_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | ▶ | next unless $entity_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | $item->{label} = $entity_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | $item->{kind} = SymbolKind__Function; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 0 | $item->{detail} = "entity macro $namespace:$entity_name"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | $item->{documentation} = "Built-in entity macro"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # Add snippets for common entity macros | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | ▶ | if ($entity_name eq 'if') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | $item->{insertText} = 'if(${1:condition}, ${2:then}, ${3:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | elsif ($entity_name eq 'unless') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | $item->{insertText} = 'unless(${1:condition}, ${2:then}, ${3:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | elsif ($entity_name eq 'ifeq') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | $item->{insertText} = 'ifeq(${1:a}, ${2:b}, ${3:then}, ${4:else});'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | ▶ | elsif ($entity_name eq 'value_checked' || $entity_name eq 'value_selected') { | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$entity_name eq "value_checked" or $entity_name eq "value_selected"
MC/DC0%0/2
$entity_name eq "value_checked" or $entity_name eq "value_selected"
$entity_name eq "value_checked"
$entity_name eq "value_selected"
Truth table0%0/3
A or B
A= $entity_name eq "value_checked"B= $entity_name eq "value_selected"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | $item->{insertText} = $entity_name . '(${1:name}, ${2:value});'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | # Default: just add semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 0 | $item->{insertText} = $entity_name . ';'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 0 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | ▶ | sub complete_entity_variables { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_variables: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | (my MY $self, my ($fileName, $namespace, $prefix, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # Find the part (widget) at the current line | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | ▶ | (my Part $part, my Template $tmpl, my $core) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | = $self->find_part_of_file_line($fileName, $line) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # List all arguments of the current widget | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | ▶ | foreach my $argName (@{$part->{_arg_order} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$part->{'_arg_order'} || []
MC/DC0%0/1
$part->{'_arg_order'} || []
$part->{'_arg_order'}
Truth table0%0/2
A
A= $part->{'_arg_order'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | ▶ | next unless $argName =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | my $arg = $part->{_arg_dict}{$argName}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | $item->{label} = $argName; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | $item->{kind} = SymbolKind__Variable; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | $item->{detail} = "var $argName" . ($arg->type ? ": " . join(":", lexpand($arg->type)) : ""); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | if ($arg->is_required) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | $item->{documentation} = "Required argument"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | # Variables just need a semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | $item->{insertText} = $argName . ';'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | $item->{insertTextFormat} = InsertTextFormat__PlainText; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 0 | ▶ | sub complete_entity_functions { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_entity_functions: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | return unless $tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | # Get the entns for this template | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | ▶ | return unless $entns; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | # Find all entity_* methods in the entns and its parents | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | my @methods = $self->list_methods_starting_with($entns, 'entity_'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | foreach my $method (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 0 | my $entity_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 0 | $entity_name =~ s/^entity_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | ▶ | next unless $entity_name =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | $item->{label} = $entity_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | $item->{kind} = SymbolKind__Function; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | $item->{detail} = "entity $namespace:$entity_name"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | $item->{documentation} = "User-defined entity function"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | # For entity functions, add parentheses and semicolon | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | $item->{insertText} = $entity_name . '($1);'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | ▶ | sub complete_declarations { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
complete_declarations: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | (my MY $self, my ($fileName, $namespace, $prefix)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | $self->debug_log("complete_declarations: prefix='$prefix'"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | ▶ | return unless $core; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | # Get the parser instance | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | my $parser = $core->Parser; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | return unless $parser; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | # Get parser class | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # Find all build_* and declare_* methods | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | my @build_methods = $self->list_methods_starting_with($parser_class, 'build_'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | my @declare_methods = $self->list_methods_starting_with($parser_class, 'declare_'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # Extract declaration names | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 0 | my %declarations; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | foreach my $method (@build_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | my $decl_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | $decl_name =~ s/^build_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | $declarations{$decl_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | foreach my $method (@declare_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 0 | my $decl_name = $method; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | $decl_name =~ s/^declare_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | $declarations{$decl_name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | # Create completion items | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | foreach my $decl (sort keys %declarations) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | ▶ | next unless $decl =~ /^\Q$prefix/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | my CompletionItem $item = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 0 | $item->{label} = $decl; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | $item->{kind} = SymbolKind__Property; # Using Property as Keyword doesn't exist | |||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | $item->{detail} = "declaration $namespace:$decl"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | $item->{documentation} = ""; # Leave documentation empty as requested | |||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | # Add snippet support for declarations | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | ▶ | if ($decl eq 'args') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | 0 | $item->{insertText} = "args \${1:arguments}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | elsif ($decl eq 'widget') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | $item->{insertText} = "widget \${1:name} \${2:args}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | elsif ($decl eq 'entity') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | $item->{insertText} = "entity \${1:name} \${2:params}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | elsif ($decl eq 'action') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | $item->{insertText} = "action \${1:name}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | elsif ($decl eq 'base') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | $item->{insertText} = "base \${1:file=\"../base.ytmpl\"}>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | # For other declarations, just add the closing > and newline | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | $item->{insertText} = "$decl \$1>\n\$0"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | $item->{insertTextFormat} = InsertTextFormat__Snippet; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 0 | push @items, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | $self->debug_log("Found " . scalar(@items) . " declarations"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | @items; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 27 | ▶ | sub locate_node_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_node_at_file_position: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 27 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 27 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | 27 | ▶ | $column //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$column //= 0
MC/DC0%0/1
$column //= 0
$column
Truth table50%1/2
A
A= $column
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 27 | ▶ | my $treeSpec = $self->dump_tokens_at_file_position($fileName, $line, $column) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 26 | my Position $pos; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 26 | $pos->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 26 | $pos->{character} = $column; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | 26 | (my ($kind, $path, $range, $tree), my Part $part) = @$treeSpec; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 26 | ▶ | unless ($self->is_in_range($range, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | # e.g. cursor past the last part. Not a symbol, not an error. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 1 | $self->debug_log("position is out of part range: range=" | |||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | .terse_dump($range)." line=$line col=$column"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | # <!yatt:action>, <!yatt:entity>... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 25 | ▶ | return if $kind eq 'body_string'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 24 | my Zipper $cursor = $self->locate_node($tree, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 24 | $self->augment_defs($cursor, $part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 24 | ▶ | sub augment_defs { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 24 | (my MY $self, my Zipper $cursor, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 24 | my $zipperList = $self->flatten_zipper_top2bottom($cursor); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 24 | my Zipper $outermost = $zipperList->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 24 | my $rangeMap = $self->arg_range_map_of_part($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 24 | my $fileName = $self->part_filename($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | $outermost->{defs}{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | //= $self->make_document_symbol_from_argument($part->{_arg_dict}{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | , $rangeMap, $fileName) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 24 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 24 | $self->augment_defs_1($zipperList, 0, $fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 24 | $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | # name => Range of each argument token written in the <!yatt:...> | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | # declaration. Args injected by argmacros and the implicit body argument | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | # have no token here. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 30 | ▶ | sub arg_range_map_of_part { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arg_range_map_of_part: called CC=8 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 30 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 30 | ▶ | my $decllist = $part->{_decllist} or return {}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 30 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 30 | my %map; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | # Reversed: the first ATTRIBUTE node of widget/page/entity/action | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | # declarations is the part name itself. An argument with the same name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | # (a later node) must win. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 30 | foreach my AltNode $node (reverse @{$self->alttree($tmpl, $decllist)}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | next unless defined $node->{kind} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 116 | ▶ | 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/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 116 | my ($name) = lexpand($node->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 116 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 116 | ▶ | $map{$name} = $node->{symbol_range} // $node->{tree_range}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$node->{"symbol_range"} // $node->{"tree_range"}
MC/DC0%0/2
$node->{"symbol_range"} // $node->{"tree_range"}
$node->{"symbol_range"}
$node->{"tree_range"}
Truth table66%2/3
A // B
A= $node->{"symbol_range"}B= $node->{"tree_range"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 30 | \%map; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 96 | ▶ | sub make_document_symbol_from_argument { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_document_symbol_from_argument: called CC=5 SCAR=16.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 96 | (my MY $self, my ($arg, $rangeMap, $fileName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 96 | my VarInfo $var = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 96 | $var->{name} = $arg->varname; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 96 | $var->{kind} = '(argument)'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 96 | $var->{type} = join(":", lexpand($arg->type)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 96 | ▶ | if (my $spec = $arg->spec_string) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 96 | $var->{detail} = qq{"$spec"}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 96 | $var->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | # A real Range (start/end), not a Position. VarTypes lineno is 1-based. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | $var->{range} = ($rangeMap && $rangeMap->{$var->{name}}) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 96 | ▶ | // $self->make_line_range(($arg->lineno // 1) - 1); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition62%5/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 table40%2/5
A and B // C
A= $rangeMapB= $$rangeMap{$var->{"name"}}C= $self->make_line_range(($arg->lineno // 1) - 1)
Truth table50%1/2
A
A= $arg->lineno
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 96 | $var; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 24 | ▶ | sub flatten_zipper_top2bottom { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flatten_zipper_top2bottom: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 24 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 24 | my @zipper; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 24 | my Zipper $c = $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 24 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 46 | unshift @zipper, $c; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | 46 | $c = $c->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | } while $c; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 24 | ▶ | wantarray ? @zipper : \@zipper; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 24 | ▶ | sub augment_defs_1 { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs_1: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 24 | (my MY $self, my ($zipperList, $depth, $fileName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 24 | my Zipper $zipper = $zipperList->[$depth]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 24 | my @nodes = @{$zipper->{array}}[0..$zipper->{index}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | # $nodes[-1] may be the undef placeholder which locate_node inserts | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | # when the cursor is between nodes. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 24 | my $current = $nodes[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 24 | foreach my AltNode $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 99 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | my $method = join("_", augment_defs_1_ => | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 98 | , $node->{kind}, lexpand($node->{path})); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 98 | ▶ | my $sub = $self->can($method) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | or next; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | 12 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | , $fileName); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 12 | ▶ | sub augment_defs_1__ELEMENT_yatt_my { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
augment_defs_1__ELEMENT_yatt_my: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 12 | (my MY $self, my Zipper $cursor, my AltNode $node | |||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | , my ($isCurrent, $fileName)) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 12 | foreach my AltNode $subNode (@{$node->{subtree}}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 12 | ▶ | next unless defined $subNode->{kind}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 12 | ▶ | next unless $subNode->{kind} eq "ATT_TEXT"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 12 | my ($name, @type) = lexpand($subNode->{path}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 12 | $cursor->{defs}{$name} = my VarInfo $var = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 12 | $var->{kind} = 'my'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 12 | $var->{name} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 12 | ▶ | $var->{type} = @type ? join(":", @type) : 'text'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 12 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 12 | $var->{filename} = $fileName; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | ▶ | sub node_path_of_zipper { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_path_of_zipper: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 0 | (my MY $self, my Zipper $cursor) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 0 | my @trail; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 0 | my Zipper $cur = $cursor; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 0 | ▶ | while ($cur) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | push @trail, do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | if (my AltNode $node = $cur->{array}[$cur->{index}]) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | $self->minimize_altnode($node); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | [map {$self->minimize_altnode($_)} @{$cur->{array}}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 0 | $cur = $cur->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | @trail; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | ▶ | sub minimize_altnode { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minimize_altnode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | (my MY $self, my AltNode $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | my AltNode $min = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | $min->{kind} = $node->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | 0 | $min->{path} = $node->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | $min->{tree_range} = $node->{tree_range}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 0 | $min; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 46 | ▶ | sub locate_node { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locate_node: called CC=8 SCAR=21.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 46 | (my MY $self, my $tree, my Position $pos, my Zipper $parent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 46 | my Zipper $current = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 46 | $current->{path} = $parent; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 46 | $current->{array} = $tree; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 46 | my $ix = $current->{index} = $self->lsearch_node_pos($pos, $tree); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 46 | ▶ | if (my AltNode $node = $tree->[$ix]) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 45 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | and $self->is_in_range($node->{symbol_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 20 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 25 | ▶ | if ($node->{subtree} | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$node->{"subtree"} and $self->is_in_range($node->{"tree_range"}, $pos)
MC/DC50%1/2
$node->{"subtree"} and $self->is_in_range($node->{"tree_range"}, $pos)
$node->{"subtree"}
$self->is_in_range($node->{"tree_range"}, $pos)
Truth table66%2/3
A and B
A= $node->{"subtree"}B= $self->is_in_range($node->{"tree_range"}, $pos)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | and $self->is_in_range($node->{tree_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 22 | return $self->locate_node($node->{subtree}, $pos, $current); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | ▶ | } elsif ($node->{tree_range} | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$node->{"tree_range"} and $self->is_in_range($node->{"tree_range"}, $pos)
MC/DC0%0/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 table33%1/3
A and B
A= $node->{"tree_range"}B= $self->is_in_range($node->{"tree_range"}, $pos)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | and $self->is_in_range($node->{tree_range}, $pos)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | # Inside a leaf node, e.g. the bare value of a=y. GH-277 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 3 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | # No yatt elements are under the position. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | splice @$tree, $ix, 0, undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | return $current; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 1 | $current; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | 46 | ▶ | sub lsearch_node_pos { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lsearch_node_pos: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 46 | (my MY $self, my Position $pos, my $tree) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 46 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 46 | foreach my AltNode $node (@$tree) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 120 | ▶ | unless (defined $node->{tree_range}) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | Carp::confess "BUG: tree_range is empty. i=$i, tree=" | |||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | . terse_dump($tree); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 120 | ▶ | if ($self->compare_position($self->range_end($node->{tree_range}), $pos) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 45 | return $i; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 75 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | # Point outside of the tree. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 1 | return scalar @$tree; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | ▶ | sub range_start { (my MY $self, my Range $range) = @_; $range->{start}; } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_start: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 120 | ▶ | sub range_end { (my MY $self, my Range $range) = @_; $range->{end}; } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range_end: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 93 | ▶ | sub is_in_range { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_range: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 93 | (my MY $self, my Range $range, my Position $pos) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | $self->compare_position($range->{start}, $pos) <= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 93 | ▶ | && $self->compare_position($range->{end}, $pos) >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 304 | ▶ | sub compare_position { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_position: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 304 | (my MY $self, my Position $leftPos, my Position $rightPos) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | $leftPos->{line} <=> $rightPos->{line} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 304 | ▶ | || $leftPos->{character} <=> $rightPos->{character}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 0 | ▶ | sub dump_part_decllist { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_part_decllist: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | 0 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table0%0/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | 0 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | $part->{_decllist} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | ▶ | sub dump_part_tree { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_part_tree: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 0 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table0%0/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 0 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | 0 | ▶ | unless (UNIVERSAL::isa($part, 'YATT::Lite::Core::Widget')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | Carp::croak "part $part->{kind} $part->{name} is not a widget"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 0 | $core->ensure_parsed($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | my Widget $widget = $part; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | $widget->{_tree} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 27 | ▶ | sub dump_tokens_at_file_position { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_tokens_at_file_position: called CC=8 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 27 | (my MY $self, my ($fileName, $line, $column)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 27 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 27 | my ($part, $tmpl, $core) = $self->find_part_of_file_line($fileName, $line); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 27 | ▶ | return unless $part; # GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 27 | ▶ | return unless defined $tmpl->{nlines}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | 27 | ▶ | unless ($line <= $tmpl->{nlines} - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | # warn? | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | # my $yatt = $self->find_yatt_for_template($fileName); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 26 | $core->ensure_parsed($part); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 26 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 26 | my $declkind = [$part->{namespace}, $part->{kind}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 26 | ▶ | if ($line < $part->{bodyln} - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | # At declaration | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | [decllist => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | , $self->part_decl_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | , $self->alttree($tmpl, $part->{_decllist}) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | } elsif (UNIVERSAL::isa($part, 'YATT::Lite::Core::Widget')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | # At body of widget, page, args... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 24 | my Widget $widget = $part; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | [body => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | , $self->part_body_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | , $self->alttree($tmpl, $widget->{_tree}) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 24 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | # At body of action, entity, ... | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | # XXX: TODO extract tokens for host language. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | [body_string => $declkind | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | , $self->part_body_range($part) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | , $part->{_toks} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 2 | , $part | |||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | 3 | ▶ | sub part_decl_range { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_decl_range: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 3 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 3 | my Range $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 3 | $range->{start} = $self->make_line_position($part->{startln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 3 | $range->{end} = $self->make_line_position($part->{bodyln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 3 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 126 | ▶ | sub make_line_position { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_line_position: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 126 | (my MY $self, my ($line, $character)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 126 | my Position $p = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | 126 | ▶ | $p->{character} = $character // 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$character // 0
MC/DC0%0/1
$character // 0
$character
Truth table50%1/2
A
A= $character
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 126 | $p->{line} = $line; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 126 | $p; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 26 | ▶ | sub part_body_range { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part_body_range: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 26 | (my MY $self, my Part $part) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 26 | my Range $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 26 | $range->{start} = $self->make_line_position($part->{bodyln} - 1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 26 | my Template $tmpl = $part->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 26 | ▶ | my $hasLastNL = $tmpl->{string} =~ /\n\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | $range->{end} = $self->make_line_position($part->{endln} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 26 | ▶ | - ($hasLastNL ? 1 : 0)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 26 | $range; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 37 | ▶ | sub find_part_of_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_part_of_file_line: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 37 | (my MY $self, my ($fileName, $line)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | 37 | ▶ | $line //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$line //= 0
MC/DC0%0/1
$line //= 0
$line
Truth table50%1/2
A
A= $line
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | 37 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 37 | my Part $prev; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 37 | foreach my Part $part ($tmpl->list_parts) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 77 | ▶ | last if $line < $part->{startln} - 1; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 44 | $prev = $part; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 37 | ▶ | wantarray ? ($prev, $tmpl, $core) : $prev; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | 39 | ▶ | sub find_template { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_template: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 39 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 39 | my ($fn, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 39 | my $yatt = $self->find_yatt_for_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 39 | my $core = $yatt->open_trans; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 39 | my $tmpl = $core->find_file($fn); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | # perl コードの生成を行わないと、継承が設定されないため。 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 39 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | 39 | $core->find_product(perl => $tmpl); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | # XXX | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 39 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 39 | ▶ | wantarray ? ($tmpl, $core) : $tmpl; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | # Forget the in-memory text (didOpen/didChange) and re-read the file from | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | # disk. apply_changes stamps mtime with the wall clock; clearing it makes | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | # refresh reload unconditionally. GH-275 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 0 | ▶ | sub reload_file_from_disk { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reload_file_from_disk: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 0 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 0 | my ($tmpl, $core) = $self->find_template($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | undef $tmpl->{mtime}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | $tmpl->refresh($core); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | $tmpl; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 39 | ▶ | sub find_yatt_for_template { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_yatt_for_template: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 39 | (my MY $self, my $fileName) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 39 | my ($fn, $dir) = File::Basename::fileparse($fileName); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 39 | $self->{_SITE}->load_yatt($dir); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 0 | ▶ | sub cmd_show_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_show_file_line: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | 0 | (my MY $self, my @desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | 0 | $self->cli_output($self->show_file_line(@desc)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | 0 | ▶ | sub show_file_line { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_file_line: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | (my MY $self, my @desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | my ($file, $line) = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | @{$desc[0]}{'file', 'line'} | |||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | @desc; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 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
}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | 0 | ▶ | open my $fh, "<:utf8", $file or Carp::croak "Can't open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | chomp(my @lines = <$fh>); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | \@lines; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | ▶ | unless (defined $line) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | 0 | Carp::croak "line is undef!"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | 0 | [@desc, $lines->[$line - $self->{line_base}]]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | 2 | ▶ | sub find_entity_from { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_entity_from: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | 2 | (my MY $self, my ($tmplOrFile, $entityName)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | 2 | ▶ | my ($tmpl) = ref $tmplOrFile ? $tmplOrFile : $self->find_template($tmplOrFile); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 2 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | 2 | ▶ | $entns->can("entity_$entityName") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 2 | +{@{$self->describe_entns_entity($entns, $entityName)}}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 6 | *cmd_list_entity = *cmd_list_entities;*cmd_list_entity = *cmd_list_entities; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | ▶ | sub cmd_list_entities { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_entities: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | my $nameRe = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | ▶ | if (my $nameGlob = shift @args) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | Text::Glob::glob_to_regex($nameGlob); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | my $emit_entities_in_entns; $emit_entities_in_entns = sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my ($entns, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | my $symtab = symtab($entns); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | my @methods = do { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | ▶ | if ($nameRe) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | sort grep { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | my $entry = $symtab->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | 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_//
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | and *{$entry}{CODE} | |||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | and (my $meth = $_) =~ s/^entity_//) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | $meth =~ $nameRe; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | } keys %$symtab; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | 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_/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | foreach my $meth (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 0 | (my $entityName = $meth) =~ s/^entity_//; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | my @result = @{$self->describe_entns_entity($entns, $entityName, path => $path)}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | $self->cli_output( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | $self->{detail} ? [[+{@result}]] : [\@result] | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | my @superNS; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | walk_vfs_folders( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | ▶ | dir => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | 0 | my ($dir, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | 0 | my $entns = $yatt->EntNS; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | ▶ | return if $seen{$entns}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | push @superNS, grep {not $seen{$_}++} $dir->get_linear_isa_of_entns; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | ▶ | file => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | my ($tmpl, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | my $entns = $tmpl->cget('entns'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | 0 | foreach my $part ($tmpl->list_parts(YATT::Lite::Core->Entity)) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | 0 | my @result = (name => $part->cget('name'), file => $tmpl->cget('path') | |||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | , line => $part->cget('startln'), entns => $entns); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | $self->cli_output( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | 0 | ▶ | $self->{detail} ? +{@result} : \@result | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | push @superNS, grep {not $seen{$_}++} $tmpl->get_linear_isa_of_entns; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 0 | foreach my $superNS (@superNS) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 0 | my $path = YATT::Lite::Util::try_invoke($superNS, 'filename'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | $emit_entities_in_entns->($superNS, $path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 2 | ▶ | sub describe_entns_entity { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe_entns_entity: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 2 | (my MY $self, my ($entns, $entityName, %opts)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 2 | my $vfs_item = $self->{_SITE}->get_yatt_by_entns($entns); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | 2 | my $entity; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | my $sub; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 2 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | and $sub = $vfs_item->can("get_type_item") | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | and $entity = $sub->($vfs_item, entity => $entityName)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | [name => $entityName, entns => $entns | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 1 | , file => $entity->{folder}{path}, line => $entity->{startln}]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | 1 | require Sub::Identify; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | 1 | my $entSub = $entns->can("entity_$entityName"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 1 | my ($file, $line) = Sub::Identify::get_code_location($entSub); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | [name => $entityName, entns => $entns | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | ▶ | sub cmd_list_vfs_folders { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_vfs_folders: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | walk_vfs_folders( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 0 | ▶ | dir => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 0 | my ($dir, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | # print join("\t", dir => $yatt->cget('dir'), $yatt->EntNS), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | 0 | my @result = (kind => 'dir', path => $dir->cget('path'), | |||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | entns => $dir->cget('entns')); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | $self->cli_output(\@result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | ▶ | file => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | my ($tmpl, $yatt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | 0 | my @result = (kind => 'dir', path => $tmpl->cget('path'), | |||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | entns => $tmpl->cget('entns')); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 0 | $self->cli_output(\@result); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | 0 | ▶ | sub cmd_list_widgets { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_widgets: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | 0 | $opts{kind} = ['widget', 'page']; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | 0 | $self->cmd_list_parts($widgetNameGlob, \%opts); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | 0 | ▶ | sub cmd_list_actions { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_actions: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | $opts{kind} = ['action']; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | $self->cmd_list_parts($widgetNameGlob, \%opts); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | ▶ | sub cmd_list_parts { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_list_parts: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 0 | (my MY $self, my @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | $self->configure($self->parse_opts(\@args)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | 0 | my $widgetNameGlob = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | 0 | ▶ | my %opts = @args == 1 ? %{$args[0]} : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | 0 | my $searchFrom = delete $opts{from}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | 0 | my $onlyKind = delete $opts{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | ▶ | if (%opts) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 0 | Carp::croak "Unknown options: ". join(", ", sort keys %opts); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | 0 | my $cwdOrFileList = $self->list_target_dirs($searchFrom); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | walk( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | factory => $self->{_SITE}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | from => $cwdOrFileList, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | ignore_symlink => $self->{ignore_symlink}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | ($widgetNameGlob ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | (name_match => Text::Glob::glob_to_regex($widgetNameGlob)) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | ) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | ▶ | widget => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | my ($found) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | 0 | my Part $widget = delete $found->{part}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | 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))
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | # XXX: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | 0 | my Template $tmpl = $widget->{folder}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | 0 | my $path = $tmpl->{path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | my $args = $self->{detail} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | ? [$self->list_part_args_internal($widget)] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | 0 | ▶ | : $widget->{_arg_order}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | # XXX: 残念ながら、encode_json の keyword 順を制御できていない | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | tie my %result, 'Tie::IxHash', ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 0 | (map {$_ => $found->{$_}} sort keys %$found) | |||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | , args => $args, path => $self->clean_path($path) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | $self->cli_output([\%result]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | 0 | ▶ | item => sub { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | 0 | my ($args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | # print "# ", $args->{_tree}->cget('path'), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | # $yatt->get_trans->list_items | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | # $yatt->get_trans->find_file('index') | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | # $yatt->get_trans->find_file('index')->list_parts | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | 0 | ▶ | sub list_part_args_internal { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_part_args_internal: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | 0 | (my MY $self, my Part $part, my $nameRe) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 0 | my @fields = YATT::Lite::VarTypes->list_field_names; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | 0 | ▶ | foreach my $argName ($part->{_arg_order} ? @{$part->{_arg_order}} : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | 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/
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | my $argObj = $part->{_arg_dict}{$argName}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | 0 | push @result, my ArgSpec $spec = {}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | foreach my $i (0 .. $#fields) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | 0 | my $val = $argObj->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | $spec->{$fields[$i]} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | # Add is_required field | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | 0 | $spec->{is_required} = $argObj->is_required; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | 0 | @result; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | 0 | ▶ | sub is_in_template_dir { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_in_template_dir: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | 0 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | 0 | my Factory $factory = $self->{_SITE}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | 0 | foreach my $dir (lexpand($factory->{_tmpldirs})) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 0 | ▶ | if (length $dir <= length $path | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/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 table0%0/3
A and B
A= length $dir <= length $pathB= substr($dir, 0, length $path) eq $path
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | and substr($dir, 0, length $path) eq $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | 0 | ▶ | sub list_target_dirs { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_target_dirs: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | 0 | (my MY $self, my $dirSpec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | 0 | ▶ | if ($dirSpec) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | 0 | $self->rel2abs($dirSpec) | |||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | my $cwd = Cwd::getcwd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | 0 | ▶ | if ($self->is_in_template_dir($cwd)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | 0 | $cwd; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 0 | ▶ | $self->{_SITE}->cget('doc_root') // do { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/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 table0%0/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!");
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | 0 | ▶ | if (my $dir = $self->{_SITE}->cget('per_role_docroot')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | 0 | [glob("$dir/[a-z]*")]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | 0 | Carp::croak "doc_root is empty!" | |||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | 6 | ▶ | MY->run(\@ARGV) unless caller; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||