blib/lib/YATT/Lite/LRXML/AltTree.pm

filter: Statementstmt 93.3% 181 / 194 Branchbran 82.0% 64 / 78 Conditioncond 72.3% 47 / 65 MC/DCmcdc 50.0% 17 / 34 Subroutinesub 91.6% 22 / 24 Podpod 0.0% 0 / 14 totaltotal 80.9% 331 / 409 CC 65 SCAR 26.5
CC
65
Cov
87%
convert_tree
31.9
fill_source_range_of
9.9
convert_entpath_args
7.3
CRAP 14.1
« blib/lib/YATT/Lite/WebMVC0/Partial/Session.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Connection.pm »
1 #!/usr/bin/env perl
2 package YATT::Lite::LRXML::AltTree;
3 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 14 ▶use File::AddInc;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use MOP4Import::Base::CLI_JSON -as_base
Subroutine BEGIN: called CC=1 SCAR=0.0
7 , [fields =>
8 [string => doc => "source template string"],
9 [with_source => default => 1, doc => "include source for intermediate nodes"],
10 [with_text => doc => "include all text node"],
11 [with_range => default => 1, doc => "include range for LSP"],
12 14 ];
13  
14 14 ▶use YATT::Lite::LanguageServer::Protocol qw/Position Range/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 use MOP4Import::Types
17 14 ▶ AltNode => [[fields => qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
18 kind path source
19 symbol_range tree_range
20 value_range
21 subtree
22 value
23 14 /]];
24  
25 use YATT::Lite::Constants
26 14 ▶ qw/NODE_TYPE
Subroutine BEGIN: called CC=1 SCAR=0.0
27 NODE_BEGIN NODE_END NODE_LNO
28 NODE_SYM_END NODE_BODY_END
29 NODE_PATH NODE_BODY NODE_VALUE
30 NODE_ATTLIST NODE_AELEM_HEAD NODE_AELEM_FOOT
31 TYPE_ELEMENT TYPE_LCMSG
32 TYPE_ATT_TEXT
33 TYPE_ATT_NAMEONLY
34 TYPE_ATT_BARENAME
35 TYPE_ATT_NESTED
36 TYPE_COMMENT
37 TYPE_ENTITY
38  
39 node_unwrap_attlist
40 14 /;
41 # XXX: Adding *TYPE_ / @TYPE_ to @YATT::Lite::Constants::EXPORT_OK didn't work
42 # Why?
43 14 *TYPES = *YATT::Lite::Constants::TYPE_;*TYPES = *YATT::Lite::Constants::TYPE_;
44 14 our @TYPES;
45  
46 14 ▶use YATT::Lite::LRXML::FormatEntpath qw/format_entpath/;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 14 ▶use MOP4Import::Util qw/lexpand/;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 14 ▶use YATT::Lite::XHF::Dumper qw/dump_xhf/;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 0 ▶sub cli_write_fh_as_xhf {
Subroutine cli_write_fh_as_xhf: not called CC=2 SCAR=17.9
Pod undocumented
51 0 (my MY $self, my ($outFH, @args)) = @_;
52 0 foreach my $list (@args) {
53 0 print $outFH $self->dump_xhf($list), "\n";
54 }
55 }
56  
57 449 ▶sub convert_tree {
Subroutine convert_tree: called CC=30 SCAR=34.6
Pod undocumented
58 449 (my MY $self, my ($tree, $with_text)) = @_;
59 449 my @result;
60 449 foreach my $item (@$tree) {
61 1317 ▶ if (not ref $item) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $item) { } 522 795 1317
elsif (not ref $item->[0] and my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")) { } 145 650 795
elsif (not ref $item->[0]) { } 650 0 650
62 522 ▶ push @result, ($with_text || $self->{with_text}) ? $item : ();
Branch: 1 branch
BranchTrueFalseTotal
$with_text || $self->{'with_text'} ? : 92 430 522
Condition66%2/3
$with_text or $self->{"with_text"}
l!l&&r!l&&!r
092430
MC/DC50%1/2
$with_text or $self->{"with_text"}
$with_text $self->{"with_text"}
Truth table66%2/3
A or B
A= $with_textB= $self->{"with_text"}
ABresult
1X1
011
000
63 ▶ } elsif (not ref $item->[NODE_TYPE] and my $sub = $self->can("convert_node__$TYPES[$item->[NODE_TYPE]]")) {
Condition66%2/3
not ref $item->[0] and my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")
!ll&&!rl&&r
0650145
MC/DC50%1/2
not ref $item->[0] and my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")
not ref $item->[0] my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")
Truth table66%2/3
not(A) and B
A= not ref $item->[0]B= my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")
ABresult
0X0
100
111
64 145 push @result, $sub->($self, $item, $with_text);
65 } elsif (not ref $item->[NODE_TYPE]) {
66 650 my AltNode $altnode = +{};
67 650 $altnode->{kind} = $TYPES[$item->[NODE_TYPE]];
68 650 $altnode->{path} = $self->convert_path_of($item);
69  
70 650 $self->fill_source_range_of($altnode, $item);
71  
72 650 ▶ if ($item->[NODE_TYPE] == TYPE_ELEMENT || $item->[NODE_TYPE] == TYPE_ATT_NESTED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[0] == 5 or $item->[0] == 9) { } 297 353 650
Condition100%3/3
$item->[0] == 5 or $item->[0] == 9
l!l&&r!l&&!r
25245353
MC/DC100%2/2
$item->[0] == 5 or $item->[0] == 9
$item->[0] == 5 $item->[0] == 9
Truth table100%3/3
A or B
A= $item->[0] == 5B= $item->[0] == 9
ABresult
1X1
011
000
73 297 my @origSubTree;
74 297 ▶ if (my $attlist = $self->node_unwrap_attlist($item->[NODE_ATTLIST])) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $attlist = $self->node_unwrap_attlist($item->[9])) 154 143 297
75 154 push @origSubTree, $attlist;
76 }
77 297 ▶ if (my $subtree = $item->[NODE_AELEM_HEAD]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subtree = $item->[10]) 13 284 297
78 13 push @origSubTree, $subtree;
79 }
80 297 ▶ if (defined $item->[NODE_BODY] and ref $item->[NODE_BODY] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $item->[8] and ref $item->[8] eq "ARRAY") 99 198 297
Condition66%2/3
defined $item->[8] and ref $item->[8] eq "ARRAY"
!ll&&!rl&&r
198099
MC/DC50%1/2
defined $item->[8] and ref $item->[8] eq "ARRAY"
defined $item->[8] ref $item->[8] eq "ARRAY"
Truth table66%2/3
A and B
A= defined $item->[8]B= ref $item->[8] eq "ARRAY"
ABresult
0X0
100
111
81 99 push @origSubTree, $self->node_body_slot($item);
82 }
83 297 ▶ if (my $subtree = $item->[NODE_AELEM_FOOT]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subtree = $item->[11]) 1 296 297
84 1 push @origSubTree, $subtree;
85 }
86 $altnode->{subtree} = [map {
87 297 $self->convert_tree($_, $with_text);
88 } @origSubTree];
89 } else {
90 353 ▶ if ($item->[NODE_TYPE] == TYPE_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($item->[0] == 1) { } 16 337 353
elsif ($item->[0] == 3) { } 0 337 337
91 16 $altnode->{value} = $item->[NODE_ATTLIST];
92 } elsif ($item->[NODE_TYPE] == TYPE_ENTITY) {
93 0 $altnode->{value} = [@{$item}[NODE_BODY .. $#$item]];
94 } else {
95 337 ▶ if (($item->[NODE_TYPE] == TYPE_ATT_TEXT
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1] and defined $item->[7]) 309 28 337
Condition91%11/12
$item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1] and defined $item->[7]
!ll&&!rl&&r
820309
$item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1]
!ll&&!rl&&r
80329
$item->[0] == 8 or $item->[0] == 6 or $item->[0] == 7
l!l&&r!l&&!r
281488
$item->[0] == 8 or $item->[0] == 6
l!l&&r!l&&!r
9218956
MC/DC80%4/5
$item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1] and defined $item->[7]
$item->[0] == 8 $item->[0] == 6 $item->[0] == 7 defined $item->[1] defined $item->[7]
Truth table50%5/10
A or B or C and D and E
A= $item->[0] == 8B= $item->[0] == 6C= $item->[0] == 7D= defined $item->[1]E= defined $item->[7]
ABCDEresult
000XX0
1XX0X0
01X0X0
0010X0
1XX100
01X100
001100
1XX111
01X111
001111
96 or $item->[NODE_TYPE] == TYPE_ATT_NAMEONLY
97 or $item->[NODE_TYPE] == TYPE_ATT_BARENAME)
98 and defined $item->[NODE_BEGIN] and defined $item->[NODE_PATH]) {
99 # symbol_range covers the attribute name. GH-277
100 # NODE_PATH may be an array ('name:type' => [name, type]).
101 # The bracket lvalue form ([a b]="v") holds nodes: no symbol then.
102 309 my @path = lexpand($item->[NODE_PATH]);
103 309 ▶ if (@path and not grep {ref $_} @path) {
Branch: 1 branch
BranchTrueFalseTotal
if (@path and not grep({ref $_;} @path)) 308 1 309
Condition66%2/3
@path and not grep({ref $_;} @path)
!ll&&!rl&&r
01308
MC/DC50%1/2
@path and not grep({ref $_;} @path)
@path not grep({ref $_;} @path)
Truth table66%2/3
A and not(B)
A= @pathB= not grep({ref $_;} @path)
ABresult
0X0
100
111
104 $altnode->{symbol_range}
105 308 = $self->make_range($item->[NODE_BEGIN]
106 , ($item->[NODE_BEGIN] + length(join ":", @path))
107 , $item->[NODE_LNO]);
108 }
109 }
110 337 ▶ if ($item->[NODE_TYPE] == TYPE_ATT_BARENAME
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[0] == 7 and defined $item->[6] and defined $item->[8] and not ref $item->[8]) 48 289 337
Condition66%6/9
$item->[0] == 7 and defined $item->[6] and defined $item->[8] and not ref $item->[8]
!ll&&!rl&&r
289048
$item->[0] == 7 and defined $item->[6] and defined $item->[8]
!ll&&!rl&&r
289048
$item->[0] == 7 and defined $item->[6]
!ll&&!rl&&r
289048
MC/DC25%1/4
$item->[0] == 7 and defined $item->[6] and defined $item->[8] and not ref $item->[8]
$item->[0] == 7 defined $item->[6] defined $item->[8] not ref $item->[8]
Truth table40%2/5
A and B and C and not(D)
A= $item->[0] == 7B= defined $item->[6]C= defined $item->[8]D= not ref $item->[8]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
111 and defined $item->[NODE_BODY_END]
112 and defined $item->[NODE_BODY] and not ref $item->[NODE_BODY]) {
113 # a=y: the bare value names a variable in scope. GH-277
114 $altnode->{value_range}
115 48 = $self->make_range($item->[NODE_BODY_END] - length($item->[NODE_BODY])
116 , $item->[NODE_BODY_END]
117 , $item->[NODE_LNO]);
118 }
119 337 ▶ if (defined $item->[NODE_BODY] and ref $item->[NODE_BODY] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $item->[8] and ref $item->[8] eq 'ARRAY') { } 48 289 337
Condition100%3/3
defined $item->[8] and ref $item->[8] eq "ARRAY"
!ll&&!rl&&r
18910048
MC/DC100%2/2
defined $item->[8] and ref $item->[8] eq "ARRAY"
defined $item->[8] ref $item->[8] eq "ARRAY"
Truth table100%3/3
A and B
A= defined $item->[8]B= ref $item->[8] eq "ARRAY"
ABresult
0X0
100
111
120 48 $altnode->{subtree} = [$self->convert_tree(
121 $self->node_body_slot($item), $with_text
122 )];
123 } else {
124 289 $altnode->{value} = $item->[NODE_BODY];
125 }
126 }
127 }
128 650 push @result, $altnode;
129 } else {
130 # XXX: Is this ok?
131 0 print STDERR "# really?: ".YATT::Lite::Util::terse_dump($tree), "\n";
132 0 ...;
133 # $self->convert_tree($item);
134 }
135 };
136  
137 449 @result;
138 }
139  
140 795 ▶sub fill_source_range_of {
Subroutine fill_source_range_of: called CC=9 SCAR=23.0
Pod undocumented
141 795 (my MY $self, my AltNode $altnode, my $orig) = @_;
142 795 ▶ if (defined $orig->[NODE_BEGIN] and defined $orig->[NODE_END]
Branch: 1 branch
BranchTrueFalseTotal
if (defined $orig->[1] and defined $orig->[2] and $orig->[1] < length $self->{"string"} and $orig->[2] <= length $self->{"string"}) 795 0 795
Condition33%3/9
defined $orig->[1] and defined $orig->[2] and $orig->[1] < length $self->{"string"} and $orig->[2] <= length $self->{"string"}
!ll&&!rl&&r
00795
defined $orig->[1] and defined $orig->[2] and $orig->[1] < length $self->{"string"}
!ll&&!rl&&r
00795
defined $orig->[1] and defined $orig->[2]
!ll&&!rl&&r
00795
MC/DC0%0/4
defined $orig->[1] and defined $orig->[2] and $orig->[1] < length $self->{"string"} and $orig->[2] <= length $self->{"string"}
defined $orig->[1] defined $orig->[2] $orig->[1] < length $self->{"string"} $orig->[2] <= length $self->{"string"}
Truth table20%1/5
A and B and C and D
A= defined $orig->[1]B= defined $orig->[2]C= $orig->[1] < length $self->{"string"}D= $orig->[2] <= length $self->{"string"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
143 and $orig->[NODE_BEGIN] < length($self->{string})
144 and $orig->[NODE_END] <= length($self->{string})) {
145 795 my $source = substr($self->{string}, $orig->[NODE_BEGIN]
146 , $orig->[NODE_END] - $orig->[NODE_BEGIN]);
147 795 ▶ if ($self->{with_source}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_source"}) 86 709 795
148 86 $altnode->{source} = $source;
149 }
150 795 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 731 64 795
151 # A <!--#yatt --> comment token includes its trailing newline
152 # (NODE_END is just after it). The range must end on the last
153 # line of the token, not at column 0..N of the next line. GH-278
154 731 my $end = $orig->[NODE_END];
155 731 ▶ if ($source =~ s/(\r?\n)\z//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($source =~ s/(\r?\n)\z//) 8 723 731
156 8 $end -= length $1;
157 }
158 731 $altnode->{tree_range} = $self->make_range(
159 $orig->[NODE_BEGIN],
160 $end,
161 $orig->[NODE_LNO],
162 ($source =~ tr|\n||)
163 );
164 731 ▶ if ($orig->[NODE_SYM_END]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig->[4]) 253 478 731
165 253 $altnode->{symbol_range} = $self->make_range(
166 $orig->[NODE_BEGIN],
167 $orig->[NODE_SYM_END] - 1,
168 $orig->[NODE_LNO],
169 );
170 }
171 }
172 }
173 }
174  
175 145 ▶sub convert_node__ENTITY {
Subroutine convert_node__ENTITY: called CC=1 SCAR=0.0
Pod undocumented
176 145 (my MY $self, my ($node, $with_text)) = @_;
177 145 my AltNode $entpathNode = {};
178 145 $entpathNode->{kind} = 'entpath';
179 145 $self->fill_source_range_of($entpathNode, $node);
180 145 my $pos = $node->[NODE_BEGIN] + length($node->[NODE_PATH]) + 1;
181 $entpathNode->{subtree} = [$self->convert_node_entpath(
182 $with_text, $pos, $node->[NODE_LNO],
183 145 @{$node}[NODE_BODY .. $#$node],
184 )];
185 145 $entpathNode;
186 }
187  
188 163 ▶sub convert_node_entpath {
Subroutine convert_node_entpath: called CC=6 SCAR=17.9
Pod undocumented
189 163 (my MY $self, my ($with_text, $pos, $line, @pathItems)) = @_;
190 163 my (@subtree);
191 163 foreach my $item (@pathItems) {
192 174 my ($kind, @args) = @$item;
193 174 ▶ if (my $sub = $self->can("convert_node_entpath__$kind")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = $self->can("convert_node_entpath__$kind")) { } 156 18 174
194 156 ▶ if (my AltNode $subtree = $sub->($self, $with_text, $pos, $line, $item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my YATT::Lite::LRXML::AltTree::AltNode $subtree = &$sub($self, $with_text, $pos, $line, $item)) { } 149 7 156
195 149 push @subtree, $subtree;
196 149 $pos += length $subtree->{source};
197 } else {
198 7 $pos += length format_entpath($item);
199 }
200 } else {
201 18 my $begin = $pos;
202 18 my $str = format_entpath($item);
203 18 my AltNode $entNode;
204 18 push @subtree, $entNode = {};
205 18 $entNode->{kind} = $kind;
206 18 $entNode->{source} = $str;
207 18 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 18 0 18
208 18 $self->convert_entpath_args($entNode, $with_text, $pos, $line, @args);
209 }
210 18 my $end = $pos += length $str;
211 18 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 18 0 18
212 18 $entNode->{tree_range} = $self->make_range($begin, $end, $line);
213 }
214 }
215 }
216 163 @subtree;
217 }
218  
219 7 ▶sub convert_node_entpath__text {
Subroutine convert_node_entpath__text: called CC=2 SCAR=8.1
Pod undocumented
220 7 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
221 7 ▶ return unless $with_text;
Branch: 1 branch
BranchTrueFalseTotal
unless $with_text 7 0 7
222 0 ...;
223 }
224  
225 41 ▶sub convert_node_entpath__call {
Subroutine convert_node_entpath__call: called CC=4 SCAR=13.9
Pod undocumented
226 41 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
227 41 my ($kind, $funcName, @args) = @$item;
228 41 my $begin = $pos;
229 41 my AltNode $entNode = {};
230 41 $entNode->{kind} = $kind;
231 41 $entNode->{path} = $funcName;
232 41 $pos += length(":$funcName(");
233 41 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 41 0 41
234 $entNode->{symbol_range}
235 41 = $self->make_range($begin, $pos, $line);
236 }
237 41 $entNode->{source} = my $str = format_entpath($item);
238 41 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 7 34 41
239 7 $self->convert_entpath_args($entNode, $with_text, $pos, $line, @args);
240 }
241 41 my $end = $begin + length $str;
242 41 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 41 0 41
243 41 $entNode->{tree_range} = $self->make_range($begin, $end, $line);
244 }
245 41 $entNode;
246 }
247  
248 14 *convert_node_entpath__invoke = *convert_node_entpath__call;
249 14 *convert_node_entpath__invoke = *convert_node_entpath__call;
250 14 *convert_node_entpath__prop = *convert_node_entpath__call;
251 14 *convert_node_entpath__prop = *convert_node_entpath__call;
252  
253 108 ▶sub convert_node_entpath__var {
Subroutine convert_node_entpath__var: called CC=2 SCAR=6.9
Pod undocumented
254 108 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
255 108 my ($kind, $varName) = @$item;
256 108 my $begin = $pos;
257 108 my AltNode $entNode = {};
258 108 $entNode->{kind} = $kind;
259 108 $entNode->{path} = $varName;
260 108 $entNode->{source} = my $str = format_entpath($item);
261 108 $pos += length($str);
262 108 my $end = $begin + length $str;
263 108 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 95 13 108
264 $entNode->{symbol_range}
265 95 = $entNode->{tree_range} = $self->make_range($begin, $end, $line);
266 }
267 108 $entNode;
268 }
269  
270 25 ▶sub convert_entpath_args {
Subroutine convert_entpath_args: called CC=6 SCAR=19.9
Pod undocumented
271 25 (my MY $self, my AltNode $entNode, my ($with_text, $pos, $line, @args)) = @_;
272 25 foreach my $arg (@args) {
273 27 ▶ if (not ref $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $arg) { } 9 18 27
274 9 $pos += length $arg;
275 } else {
276 18 ▶ if (ref $arg eq 'ARRAY' and ref $arg->[0] eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $arg eq 'ARRAY' and ref $arg->[0] eq 'ARRAY') { } 0 18 18
elsif (ref $arg eq 'ARRAY') { } 18 0 18
Condition33%1/3
ref $arg eq "ARRAY" and ref $arg->[0] eq "ARRAY"
!ll&&!rl&&r
0180
MC/DC0%0/2
ref $arg eq "ARRAY" and ref $arg->[0] eq "ARRAY"
ref $arg eq "ARRAY" ref $arg->[0] eq "ARRAY"
Truth table33%1/3
A and B
A= ref $arg eq "ARRAY"B= ref $arg->[0] eq "ARRAY"
ABresult
0X0
100
111
277 # pipeline
278 0 push @{$entNode->{subtree}}
279 , $self->convert_node_entpath($with_text, $pos, $line, @$arg);
280 } elsif (ref $arg eq 'ARRAY') {
281 # single item
282 18 push @{$entNode->{subtree}}
283 , $self->convert_node_entpath($with_text, $pos, $line, $arg);
284 } else {
285 0 die "Really?";
286 }
287 18 $pos += length format_entpath(YATT::Lite::Constants::lxnest($arg));
288 }
289 } continue {
290 27 $pos += length(",");
291 }
292 }
293  
294 1535 ▶sub make_range {
Subroutine make_range: called CC=2 SCAR=6.9
Pod undocumented
295 1535 (my MY $self, my ($begin, $end, $lineno, $nlines)) = @_;
296 1535 my Range $range = +{};
297 1535 $range->{start} = do {
298 1535 my Position $p;
299 1535 $p->{character} = $self->column_of_source_pos($self->{string}, $begin)-1;
300 1535 $p->{line} = $lineno - 1;
301 1535 $p;
302 };
303 1535 $range->{end} = do {
304 1535 my Position $p;
305 1535 $p->{character} = $self->column_of_source_pos($self->{string}, $end-1, 1);
306 1535 ▶ $p->{line} = $lineno - 1 + ($nlines // 0);
Condition100%2/2
$nlines // 0
l!l
731804
MC/DC100%1/1
$nlines // 0
$nlines
Truth table100%2/2
A
A= $nlines
Aresult
11
00
307 1535 $p;
308 };
309 1535 $range;
310 }
311  
312 3070 ▶sub column_of_source_pos {
Subroutine column_of_source_pos: called CC=3 SCAR=12.0
Pod undocumented
313 3070 my $pos = $_[2];
314 3070 ▶ if ($_[3] and substr($_[1], $pos, 1) eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3] and substr($_[1], $pos, 1) eq "\n") 0 3070 3070
Condition66%2/3
$_[3] and substr($_[1], $pos, 1) eq "\n"
!ll&&!rl&&r
153515350
MC/DC0%0/2
$_[3] and substr($_[1], $pos, 1) eq "\n"
$_[3] substr($_[1], $pos, 1) eq "\n"
Truth table66%2/3
A and B
A= $_[3]B= substr($_[1], $pos, 1) eq "\n"
ABresult
0X0
100
111
315 0 $pos--;
316 }
317 # 1-based column. rindex gives -1 on the first line, which yields the
318 # same 1-based column as on the other lines. GH-275
319 3070 $pos - rindex($_[1], "\n", $pos);
320 }
321  
322 147 ▶sub node_body_slot {
Subroutine node_body_slot: called CC=5 SCAR=16.3
Pod undocumented
323 147 my ($self, $node) = @_;
324 147 ▶ if ($node->[NODE_TYPE] == TYPE_ELEMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0] == 5) { } 54 93 147
elsif ($node->[0] == 2) { } 2 91 93
325 54 ▶ return $node->[NODE_BODY] ? $node->[NODE_BODY][NODE_VALUE] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->[8] ? : 54 0 54
326 } elsif ($node->[NODE_TYPE] == TYPE_LCMSG) {
327 2 ▶ return $node->[NODE_BODY] ? $node->[NODE_BODY][0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->[8] ? : 2 0 2
328 } else {
329 91 return $node->[NODE_VALUE];
330 }
331 }
332  
333 650 ▶sub convert_path_of {
Subroutine convert_path_of: called CC=5 SCAR=16.1
Pod undocumented
334 650 my ($self, $node) = @_;
335 650 my $path = $node->[NODE_PATH];
336 650 ▶ if ($path and ref $path and @$path and ref $path->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path and ref $path and @$path and ref $path->[0]) { } 1 649 650
Condition88%8/9
$path and ref $path and @$path and ref $path->[0]
!ll&&!rl&&r
3512981
$path and ref $path and @$path
!ll&&!rl&&r
3510299
$path and ref $path
!ll&&!rl&&r
21330299
MC/DC75%3/4
$path and ref $path and @$path and ref $path->[0]
$path ref $path @$path ref $path->[0]
Truth table80%4/5
A and B and C and D
A= $pathB= ref $pathC= @$pathD= ref $path->[0]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
337 1 [$self->convert_tree($path, 1)]; # with_text
338 } else {
339 649 $path;
340 }
341 }
342  
343 0 ▶sub list_types {
Subroutine list_types: not called CC=1 SCAR=6.9
Pod undocumented
344 0 @TYPES;
345 }
346  
347 14 ▶MY->run(\@ARGV) unless caller;
Branch: 1 branch
BranchTrueFalseTotal
unless caller 0 14 14
348 14 1;
« blib/lib/YATT/Lite/WebMVC0/Partial/Session.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Connection.pm »