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

filter: Statementstmt 93.1% 178 / 191 Branchbran 81.5% 62 / 76 Conditioncond 72.3% 47 / 65 MC/DCmcdc 50.0% 17 / 34 Subroutinesub 91.6% 22 / 24 Podpod 0.0% 0 / 14 totaltotal 80.6% 326 / 404 CC 64 SCAR 26.5
CC
64
Cov
86%
convert_tree
31.9
fill_source_range_of
9.2
convert_entpath_args
7.3
CRAP 14.1
« blib/lib/YATT/Lite/Util/FindMethods.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Connection.pm »
1 #!/usr/bin/env perl
2 package YATT::Lite::LRXML::AltTree;
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use File::AddInc;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶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 8 ];
13  
14 8 ▶use YATT::Lite::LanguageServer::Protocol qw/Position Range/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 use MOP4Import::Types
17 8 ▶ 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 8 /]];
24  
25 use YATT::Lite::Constants
26 8 ▶ 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 8 /;
41 # XXX: Adding *TYPE_ / @TYPE_ to @YATT::Lite::Constants::EXPORT_OK didn't work
42 # Why?
43 8 *TYPES = *YATT::Lite::Constants::TYPE_;*TYPES = *YATT::Lite::Constants::TYPE_;
44 8 our @TYPES;
45  
46 8 ▶use YATT::Lite::LRXML::FormatEntpath qw/format_entpath/;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 8 ▶use MOP4Import::Util qw/lexpand/;
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 8 ▶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 265 ▶sub convert_tree {
Subroutine convert_tree: called CC=30 SCAR=34.6
Pod undocumented
58 265 (my MY $self, my ($tree, $with_text)) = @_;
59 265 my @result;
60 265 foreach my $item (@$tree) {
61 840 ▶ if (not ref $item) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $item) { } 326 514 840
elsif (not ref $item->[0] and my $sub = $self->can("convert_node__$YATT::Lite::LRXML::AltTree::TYPES[$item->[0]]")) { } 79 435 514
elsif (not ref $item->[0]) { } 435 0 435
62 326 ▶ push @result, ($with_text || $self->{with_text}) ? $item : ();
Branch: 1 branch
BranchTrueFalseTotal
$with_text || $self->{'with_text'} ? : 84 242 326
Condition66%2/3
$with_text or $self->{"with_text"}
l!l&&r!l&&!r
084242
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
043579
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 79 push @result, $sub->($self, $item, $with_text);
65 } elsif (not ref $item->[NODE_TYPE]) {
66 435 my AltNode $altnode = +{};
67 435 $altnode->{kind} = $TYPES[$item->[NODE_TYPE]];
68 435 $altnode->{path} = $self->convert_path_of($item);
69  
70 435 $self->fill_source_range_of($altnode, $item);
71  
72 435 ▶ if ($item->[NODE_TYPE] == TYPE_ELEMENT || $item->[NODE_TYPE] == TYPE_ATT_NESTED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->[0] == 5 or $item->[0] == 9) { } 173 262 435
Condition100%3/3
$item->[0] == 5 or $item->[0] == 9
l!l&&r!l&&!r
15122262
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 173 my @origSubTree;
74 173 ▶ if (my $attlist = $self->node_unwrap_attlist($item->[NODE_ATTLIST])) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $attlist = $self->node_unwrap_attlist($item->[9])) 118 55 173
75 118 push @origSubTree, $attlist;
76 }
77 173 ▶ if (my $subtree = $item->[NODE_AELEM_HEAD]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subtree = $item->[10]) 13 160 173
78 13 push @origSubTree, $subtree;
79 }
80 173 ▶ 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") 43 130 173
Condition66%2/3
defined $item->[8] and ref $item->[8] eq "ARRAY"
!ll&&!rl&&r
130043
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 43 push @origSubTree, $self->node_body_slot($item);
82 }
83 173 ▶ if (my $subtree = $item->[NODE_AELEM_FOOT]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $subtree = $item->[11]) 1 172 173
84 1 push @origSubTree, $subtree;
85 }
86 $altnode->{subtree} = [map {
87 173 $self->convert_tree($_, $with_text);
88 } @origSubTree];
89 } else {
90 262 ▶ if ($item->[NODE_TYPE] == TYPE_COMMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($item->[0] == 1) { } 8 254 262
elsif ($item->[0] == 3) { } 0 254 254
91 8 $altnode->{value} = $item->[NODE_ATTLIST];
92 } elsif ($item->[NODE_TYPE] == TYPE_ENTITY) {
93 0 $altnode->{value} = [@{$item}[NODE_BODY .. $#$item]];
94 } else {
95 254 ▶ 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]) 245 9 254
Condition91%11/12
$item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1] and defined $item->[7]
!ll&&!rl&&r
81245
$item->[0] == 8 || $item->[0] == 6 || $item->[0] == 7 and defined $item->[1]
!ll&&!rl&&r
80246
$item->[0] == 8 or $item->[0] == 6 or $item->[0] == 7
l!l&&r!l&&!r
204428
$item->[0] == 8 or $item->[0] == 6
l!l&&r!l&&!r
5914550
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 245 my @path = lexpand($item->[NODE_PATH]);
103 245 ▶ if (@path and not grep {ref $_} @path) {
Branch: 1 branch
BranchTrueFalseTotal
if (@path and not grep({ref $_;} @path)) 244 1 245
Condition66%2/3
@path and not grep({ref $_;} @path)
!ll&&!rl&&r
01244
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 244 = $self->make_range($item->[NODE_BEGIN]
106 , ($item->[NODE_BEGIN] + length(join ":", @path))
107 , $item->[NODE_LNO]);
108 }
109 }
110 254 ▶ 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]) 42 212 254
Condition66%6/9
$item->[0] == 7 and defined $item->[6] and defined $item->[8] and not ref $item->[8]
!ll&&!rl&&r
212042
$item->[0] == 7 and defined $item->[6] and defined $item->[8]
!ll&&!rl&&r
212042
$item->[0] == 7 and defined $item->[6]
!ll&&!rl&&r
212042
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 42 = $self->make_range($item->[NODE_BODY_END] - length($item->[NODE_BODY])
116 , $item->[NODE_BODY_END]
117 , $item->[NODE_LNO]);
118 }
119 254 ▶ 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') { } 18 236 254
Condition100%3/3
defined $item->[8] and ref $item->[8] eq "ARRAY"
!ll&&!rl&&r
1459118
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 18 $altnode->{subtree} = [$self->convert_tree(
121 $self->node_body_slot($item), $with_text
122 )];
123 } else {
124 236 $altnode->{value} = $item->[NODE_BODY];
125 }
126 }
127 }
128 435 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 265 @result;
138 }
139  
140 514 ▶sub fill_source_range_of {
Subroutine fill_source_range_of: called CC=8 SCAR=22.2
Pod undocumented
141 514 (my MY $self, my AltNode $altnode, my $orig) = @_;
142 514 ▶ 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"}) 514 0 514
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
00514
defined $orig->[1] and defined $orig->[2] and $orig->[1] < length $self->{"string"}
!ll&&!rl&&r
00514
defined $orig->[1] and defined $orig->[2]
!ll&&!rl&&r
00514
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 514 my $source = substr($self->{string}, $orig->[NODE_BEGIN]
146 , $orig->[NODE_END] - $orig->[NODE_BEGIN]);
147 514 ▶ if ($self->{with_source}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_source"}) 78 436 514
148 78 $altnode->{source} = $source;
149 }
150 514 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 450 64 514
151 450 $altnode->{tree_range} = $self->make_range(
152 $orig->[NODE_BEGIN],
153 $orig->[NODE_END],
154 $orig->[NODE_LNO],
155 ($source =~ tr|\n||)
156 );
157 450 ▶ if ($orig->[NODE_SYM_END]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig->[4]) 152 298 450
158 152 $altnode->{symbol_range} = $self->make_range(
159 $orig->[NODE_BEGIN],
160 $orig->[NODE_SYM_END] - 1,
161 $orig->[NODE_LNO],
162 );
163 }
164 }
165 }
166 }
167  
168 79 ▶sub convert_node__ENTITY {
Subroutine convert_node__ENTITY: called CC=1 SCAR=0.0
Pod undocumented
169 79 (my MY $self, my ($node, $with_text)) = @_;
170 79 my AltNode $entpathNode = {};
171 79 $entpathNode->{kind} = 'entpath';
172 79 $self->fill_source_range_of($entpathNode, $node);
173 79 my $pos = $node->[NODE_BEGIN] + length($node->[NODE_PATH]) + 1;
174 $entpathNode->{subtree} = [$self->convert_node_entpath(
175 $with_text, $pos, $node->[NODE_LNO],
176 79 @{$node}[NODE_BODY .. $#$node],
177 )];
178 79 $entpathNode;
179 }
180  
181 92 ▶sub convert_node_entpath {
Subroutine convert_node_entpath: called CC=6 SCAR=17.9
Pod undocumented
182 92 (my MY $self, my ($with_text, $pos, $line, @pathItems)) = @_;
183 92 my (@subtree);
184 92 foreach my $item (@pathItems) {
185 103 my ($kind, @args) = @$item;
186 103 ▶ if (my $sub = $self->can("convert_node_entpath__$kind")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = $self->can("convert_node_entpath__$kind")) { } 85 18 103
187 85 ▶ 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)) { } 83 2 85
188 83 push @subtree, $subtree;
189 83 $pos += length $subtree->{source};
190 } else {
191 2 $pos += length format_entpath($item);
192 }
193 } else {
194 18 my $begin = $pos;
195 18 my $str = format_entpath($item);
196 18 my AltNode $entNode;
197 18 push @subtree, $entNode = {};
198 18 $entNode->{kind} = $kind;
199 18 $entNode->{source} = $str;
200 18 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 18 0 18
201 18 $self->convert_entpath_args($entNode, $with_text, $pos, $line, @args);
202 }
203 18 my $end = $pos += length $str;
204 18 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 18 0 18
205 18 $entNode->{tree_range} = $self->make_range($begin, $end, $line);
206 }
207 }
208 }
209 92 @subtree;
210 }
211  
212 2 ▶sub convert_node_entpath__text {
Subroutine convert_node_entpath__text: called CC=2 SCAR=8.1
Pod undocumented
213 2 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
214 2 ▶ return unless $with_text;
Branch: 1 branch
BranchTrueFalseTotal
unless $with_text 2 0 2
215 0 ...;
216 }
217  
218 22 ▶sub convert_node_entpath__call {
Subroutine convert_node_entpath__call: called CC=4 SCAR=13.9
Pod undocumented
219 22 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
220 22 my ($kind, $funcName, @args) = @$item;
221 22 my $begin = $pos;
222 22 my AltNode $entNode = {};
223 22 $entNode->{kind} = $kind;
224 22 $entNode->{path} = $funcName;
225 22 $pos += length(":$funcName(");
226 22 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 22 0 22
227 $entNode->{symbol_range}
228 22 = $self->make_range($begin, $pos, $line);
229 }
230 22 $entNode->{source} = my $str = format_entpath($item);
231 22 ▶ if (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 2 20 22
232 2 $self->convert_entpath_args($entNode, $with_text, $pos, $line, @args);
233 }
234 22 my $end = $begin + length $str;
235 22 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 22 0 22
236 22 $entNode->{tree_range} = $self->make_range($begin, $end, $line);
237 }
238 22 $entNode;
239 }
240  
241 8 *convert_node_entpath__invoke = *convert_node_entpath__call;
242 8 *convert_node_entpath__invoke = *convert_node_entpath__call;
243 8 *convert_node_entpath__prop = *convert_node_entpath__call;
244 8 *convert_node_entpath__prop = *convert_node_entpath__call;
245  
246 61 ▶sub convert_node_entpath__var {
Subroutine convert_node_entpath__var: called CC=2 SCAR=6.9
Pod undocumented
247 61 (my MY $self, my ($with_text, $pos, $line, $item)) = @_;
248 61 my ($kind, $varName) = @$item;
249 61 my $begin = $pos;
250 61 my AltNode $entNode = {};
251 61 $entNode->{kind} = $kind;
252 61 $entNode->{path} = $varName;
253 61 $entNode->{source} = my $str = format_entpath($item);
254 61 $pos += length($str);
255 61 my $end = $begin + length $str;
256 61 ▶ if ($self->{with_range}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"with_range"}) 48 13 61
257 $entNode->{symbol_range}
258 48 = $entNode->{tree_range} = $self->make_range($begin, $end, $line);
259 }
260 61 $entNode;
261 }
262  
263 20 ▶sub convert_entpath_args {
Subroutine convert_entpath_args: called CC=6 SCAR=19.9
Pod undocumented
264 20 (my MY $self, my AltNode $entNode, my ($with_text, $pos, $line, @args)) = @_;
265 20 foreach my $arg (@args) {
266 22 ▶ if (not ref $arg) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $arg) { } 9 13 22
267 9 $pos += length $arg;
268 } else {
269 13 ▶ 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 13 13
elsif (ref $arg eq 'ARRAY') { } 13 0 13
Condition33%1/3
ref $arg eq "ARRAY" and ref $arg->[0] eq "ARRAY"
!ll&&!rl&&r
0130
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
270 # pipeline
271 0 push @{$entNode->{subtree}}
272 , $self->convert_node_entpath($with_text, $pos, $line, @$arg);
273 } elsif (ref $arg eq 'ARRAY') {
274 # single item
275 13 push @{$entNode->{subtree}}
276 , $self->convert_node_entpath($with_text, $pos, $line, $arg);
277 } else {
278 0 die "Really?";
279 }
280 13 $pos += length format_entpath(YATT::Lite::Constants::lxnest($arg));
281 }
282 } continue {
283 22 $pos += length(",");
284 }
285 }
286  
287 998 ▶sub make_range {
Subroutine make_range: called CC=2 SCAR=6.9
Pod undocumented
288 998 (my MY $self, my ($begin, $end, $lineno, $nlines)) = @_;
289 998 my Range $range = +{};
290 998 $range->{start} = do {
291 998 my Position $p;
292 998 $p->{character} = $self->column_of_source_pos($self->{string}, $begin)-1;
293 998 $p->{line} = $lineno - 1;
294 998 $p;
295 };
296 998 $range->{end} = do {
297 998 my Position $p;
298 998 $p->{character} = $self->column_of_source_pos($self->{string}, $end-1, 1);
299 998 ▶ $p->{line} = $lineno - 1 + ($nlines // 0);
Condition100%2/2
$nlines // 0
l!l
450548
MC/DC100%1/1
$nlines // 0
$nlines
Truth table100%2/2
A
A= $nlines
Aresult
11
00
300 998 $p;
301 };
302 998 $range;
303 }
304  
305 1996 ▶sub column_of_source_pos {
Subroutine column_of_source_pos: called CC=3 SCAR=12.0
Pod undocumented
306 1996 my $pos = $_[2];
307 1996 ▶ if ($_[3] and substr($_[1], $pos, 1) eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3] and substr($_[1], $pos, 1) eq "\n") 0 1996 1996
Condition66%2/3
$_[3] and substr($_[1], $pos, 1) eq "\n"
!ll&&!rl&&r
9989980
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
308 0 $pos--;
309 }
310 # 1-based column. rindex gives -1 on the first line, which yields the
311 # same 1-based column as on the other lines. GH-275
312 1996 $pos - rindex($_[1], "\n", $pos);
313 }
314  
315 61 ▶sub node_body_slot {
Subroutine node_body_slot: called CC=5 SCAR=16.3
Pod undocumented
316 61 my ($self, $node) = @_;
317 61 ▶ if ($node->[NODE_TYPE] == TYPE_ELEMENT) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0] == 5) { } 21 40 61
elsif ($node->[0] == 2) { } 2 38 40
318 21 ▶ return $node->[NODE_BODY] ? $node->[NODE_BODY][NODE_VALUE] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->[8] ? : 21 0 21
319 } elsif ($node->[NODE_TYPE] == TYPE_LCMSG) {
320 2 ▶ return $node->[NODE_BODY] ? $node->[NODE_BODY][0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$node->[8] ? : 2 0 2
321 } else {
322 38 return $node->[NODE_VALUE];
323 }
324 }
325  
326 435 ▶sub convert_path_of {
Subroutine convert_path_of: called CC=5 SCAR=16.1
Pod undocumented
327 435 my ($self, $node) = @_;
328 435 my $path = $node->[NODE_PATH];
329 435 ▶ 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 434 435
Condition88%8/9
$path and ref $path and @$path and ref $path->[0]
!ll&&!rl&&r
2481861
$path and ref $path and @$path
!ll&&!rl&&r
2480187
$path and ref $path
!ll&&!rl&&r
2246187
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
330 1 [$self->convert_tree($path, 1)]; # with_text
331 } else {
332 434 $path;
333 }
334 }
335  
336 0 ▶sub list_types {
Subroutine list_types: not called CC=1 SCAR=6.9
Pod undocumented
337 0 @TYPES;
338 }
339  
340 8 ▶MY->run(\@ARGV) unless caller;
Branch: 1 branch
BranchTrueFalseTotal
unless caller 0 8 8
341 8 1;
« blib/lib/YATT/Lite/Util/FindMethods.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Connection.pm »