lib/WWW/Shopify/Liquid/Parser.pm

filter: Statementstmt 9.0% 27 / 299 Branchbran 0.0% 0 / 158 Conditioncond 0.0% 0 / 90 MC/DCmcdc 0.0% 0 / 50 Subroutinesub 21.4% 9 / 42 Podpod n/a totaltotal 5.6% 36 / 639 CC 126 SCAR 61.2
CC
126
Cov
5%
parse_argument_tokens
1332.0
parse_inner_tokens
812.0
unparse_tokens
182.0
CRAP 455.3
« lib/WWW/Shopify/Liquid/Tag/Assign.pm ↑ Summary lib/WWW/Shopify/Liquid/Tag/For.pm »
1 #!/usr/bin/perl
2  
3 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package WWW::Shopify::Liquid::Parser;
7 38 ▶use base 'WWW::Shopify::Liquid::Pipeline';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 38 ▶use Module::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 38 ▶use List::MoreUtils qw(firstidx part);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 38 ▶use WWW::Shopify::Liquid::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 useall WWW::Shopify::Liquid::Operator;
14 useall WWW::Shopify::Liquid::Tag;
15 useall WWW::Shopify::Liquid::Filter;
16  
17 0 ▶sub new { return bless {
Subroutine new: not called CC=1 SCAR=6.9
18 # Internal
19 order_of_operations => [],
20 operators => {},
21 enclosing_tags => {},
22 free_tags => {},
23 filters => {},
24 inner_tags => {},
25 security => WWW::Shopify::Liquid::Security->new,
26
27 # Determines whether or not we should error on finding a filter we don't recognize. Can be useful for parsing, without actually rendering ot have this on.
28 # No tag version, because we need to know whether a tag is free or enclosing to parse correctly.
29 accept_unknown_filters => 0,
30 # Determines whether we clear the custom tag/filter cache after each parse. For security purposes, should be true by default,
31 # or custom tags should be disabled entirely.
32 transient_custom_operations => 1,
33 custom_tags => {},
34 custom_filters => {},
35 transient_elements => []
36 }, $_[0]; }
37 0 ▶sub accept_unknown_filters { $_[0]->{accept_unknown_filters} = $_[1] if defined $_[1]; return $_[0]->{accept_unknown_filters}; }
Subroutine accept_unknown_filters: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
38 0 ▶sub accept_method_calls { $_[0]->{accept_method_calls} = $_[1] if defined $_[1]; return $_[0]->{accept_method_calls}; }
Subroutine accept_method_calls: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
39 0 ▶sub transient_custom_operations { $_[0]->{transient_custom_operations} = $_[1] if defined $_[1]; return $_[0]->{transient_custom_operations}; }
Subroutine transient_custom_operations: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
40 0 ▶sub custom_tags { return $_[0]->{custom_tags}; }
Subroutine custom_tags: not called CC=1 SCAR=6.9
41 0 ▶sub custom_filters { return $_[0]->{custom_filters}; }
Subroutine custom_filters: not called CC=1 SCAR=6.9
42 0 ▶sub operator { return $_[0]->{operators}->{$_[1]}; }
Subroutine operator: not called CC=1 SCAR=6.9
43 0 ▶sub operators { return $_[0]->{operators}; }
Subroutine operators: not called CC=1 SCAR=6.9
44 0 ▶sub order_of_operations { return @{$_[0]->{order_of_operations}}; }
Subroutine order_of_operations: not called CC=1 SCAR=6.9
45 0 ▶sub free_tags { return $_[0]->{free_tags}; }
Subroutine free_tags: not called CC=1 SCAR=6.9
46 0 ▶sub enclosing_tags { return $_[0]->{enclosing_tags}; }
Subroutine enclosing_tags: not called CC=1 SCAR=6.9
47 0 ▶sub inner_tags { return $_[0]->{inner_tags}; }
Subroutine inner_tags: not called CC=1 SCAR=6.9
48 0 ▶sub filters { return $_[0]->{filters}; }
Subroutine filters: not called CC=1 SCAR=6.9
49  
50 0 ▶sub register_tag {
Subroutine register_tag: not called CC=4 SCAR=30.0
51 0 my ($self, $tag) = @_;
52 0 $self->SUPER::register_tag($tag);
53 0 ▶ $self->free_tags->{$tag->name} = $tag if $tag->is_free;
Branch: 1 branch
BranchTrueFalseTotal
if $tag->is_free 0 0 0
54 0 ▶ if ($tag->is_enclosing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->is_enclosing) 0 0 0
55 0 $self->enclosing_tags->{$tag->name} = $tag;
56 0 foreach my $inner_tag ($tag->inner_tags) {
57 0 $self->inner_tags->{$inner_tag} = 1;
58 }
59 }
60 }
61  
62 0 ▶sub register_operator {
Subroutine register_operator: not called CC=3 SCAR=24.8
63 0 $_[0]->SUPER::register_operator($_[1]);
64 0 $_[0]->operators->{$_} = $_[1] for($_[1]->symbol);
65 0 my $ooo = $_[0]->{order_of_operations};
66 0 ▶ my $element = first { $_->[0]->priority == $_[1]->priority } @$ooo;
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 ▶ if ($element) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element) { } 0 0 0
68 0 push(@$element, $_[1]);
69 }
70 else {
71 0 push(@$ooo, [$_[1]]);
72 }
73 0 $_[0]->{order_of_operations} = [sort { $b->[0]->priority <=> $a->[0]->priority } @$ooo];
74 }
75 0 ▶sub register_filter {
Subroutine register_filter: not called CC=1 SCAR=6.9
76 0 $_[0]->SUPER::register_filter($_[1]);
77 0 $_[0]->filters->{$_[1]->name} = $_[1];
78 }
79  
80 0 ▶sub deregister_tag {
Subroutine deregister_tag: not called CC=6 SCAR=37.4
81 0 my ($self, $tag) = @_;
82 0 $self->SUPER::deregister_tag($tag);
83 0 ▶ if ($tag->is_enclosing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->is_enclosing) { } 0 0 0
84 0 ▶ delete $self->enclosing_tags->{$tag->name} if $self->enclosing_tags->{$tag->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->enclosing_tags->{$tag->name} 0 0 0
85 0 foreach my $inner_tag ($tag->inner_tags) {
86 0 ▶ delete $self->inner_tags->{$inner_tag} if $self->inner_tags->{$inner_tag};
Branch: 1 branch
BranchTrueFalseTotal
if $self->inner_tags->{$inner_tag} 0 0 0
87 }
88 } else {
89 0 ▶ delete $self->free_tags->{$tag->name} if $self->free_tags->{$tag->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->free_tags->{$tag->name} 0 0 0
90 }
91 }
92 0 ▶sub deregister_filter {
Subroutine deregister_filter: not called CC=2 SCAR=17.9
93 0 my ($self, $filter) = @_;
94 0 $self->SUPER::deregister_filter($filter);
95 0 ▶ delete $self->filters->{$filter->name} if $self->filters->{$filter->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->filters->{$filter->name} 0 0 0
96 }
97  
98  
99 0 ▶sub parse_filter_tokens {
Subroutine parse_filter_tokens: not called CC=11 SCAR=48.8
100 0 my ($self, $initial, @tokens) = @_;
101 0 my $filter = shift(@tokens);
102 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser($initial, "Each filter requires exactly one operand.") unless $filter;
Branch: 1 branch
BranchTrueFalseTotal
unless $filter 0 0 0
103 0 ▶ my $filter_name = $filter->isa('WWW::Shopify::Liquid::Token::Operator') ? $filter->{core} : $filter->{core}->[0]->{core};
Branch: 1 branch
BranchTrueFalseTotal
$filter->isa('WWW::Shopify::Liquid::Token::Operator') ? : 0 0 0
104 # TODO God, this is stupid, but temporary patch.
105 0 my $filter_package;
106 0 ▶ if ($filter_name =~ m/::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filter_name =~ /::/) { } 0 0 0
107 0 $filter_package = $filter_name;
108 0 eval { $filter_package->name };
109 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
110 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::UnknownFilter($filter) if !$self->accept_unknown_filters;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->accept_unknown_filters 0 0 0
111 0 $filter_package = 'WWW::Shopify::Liquid::Filter::Unknown';
112 }
113 } else {
114 0 ▶ if (!$self->{filters}->{$filter_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'filters'}{$filter_name}) { } 0 0 0
115 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::UnknownFilter($filter) if !$self->accept_unknown_filters;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->accept_unknown_filters 0 0 0
116 0 $filter_package = 'WWW::Shopify::Liquid::Filter::Unknown';
117 } else {
118 0 $filter_package = $self->{filters}->{$filter_name};
119 }
120 }
121 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Arguments($filter, "In order to have arguments, filter must be followed by a colon.") if int(@tokens) > 0 && $tokens[0]->{core} ne ":";
Branch: 1 branch
BranchTrueFalseTotal
if int @tokens > 0 and $tokens[0]{"core"} ne ":" 0 0 0
Condition0%0/3
int @tokens > 0 and $tokens[0]{"core"} ne ":"
!ll&&!rl&&r
000
MC/DC0%0/2
int @tokens > 0 and $tokens[0]{"core"} ne ":"
int @tokens > 0 $tokens[0]{"core"} ne ":"
Truth table0%0/3
A and B
A= int @tokens > 0B= $tokens[0]{"core"} ne ":"
ABresult
0X0
100
111
122
123 0 my @arguments = ();
124 # Get rid of our colon.
125 0 ▶ if (shift(@tokens)) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @tokens) 0 0 0
126 0 my $i = 0;
127 0 ▶ @arguments = map { $self->parse_argument_tokens(grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @{$_}) } part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Separator') && $_->{core} eq ","; $i; } @tokens;
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if $_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq "," 0 0 0
Condition0%0/3
$_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq ","
!ll&&!rl&&r
000
MC/DC0%0/2
$_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq ","
$_->isa("WWW::Shopify::Liquid::Token::Separator") $_->{"core"} eq ","
Truth table0%0/3
A and B
A= $_->isa("WWW::Shopify::Liquid::Token::Separator")B= $_->{"core"} eq ","
ABresult
0X0
100
111
128 }
129 0 $filter = $filter_package->new($self, $filter->{line}, $filter_name, $initial, @arguments);
130 0 $filter->verify($self);
131 0 return $filter;
132 }
133 38 ▶use List::MoreUtils qw(part);
Subroutine BEGIN: called CC=1 SCAR=0.0
134  
135 0 ▶sub walk_groupings {
Subroutine walk_groupings: not called CC=4 SCAR=30.0
136 0 my ($self, $aggregate) = @_;
137 0 for (grep {
138 0 $aggregate->{members}->[$_]->isa('WWW::Shopify::Liquid::Token::Grouping')
139 0 } 0..(int(@{$aggregate->{members}})-1)) {
140 0 ($aggregate->{members}->[$_]) = $self->parse_argument_tokens($aggregate->{members}->[$_]->members);
141 }
142 0 ▶ $self->walk_groupings($_) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array') } $aggregate->members);
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array')
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array')
$_->isa('WWW::Shopify::Liquid::Token::Hash') $_->isa('WWW::Shopify::Liquid::Token::Array')
Truth table0%0/3
A || B
A= $_->isa('WWW::Shopify::Liquid::Token::Hash')B= $_->isa('WWW::Shopify::Liquid::Token::Array')
ABresult
1X1
011
000
143
144 }
145  
146 # Similar, but doesn't deal with tags; deals solely with order of operations.
147 0 ▶sub parse_argument_tokens {
Subroutine parse_argument_tokens: not called CC=36 SCAR=71.9
148 0 my ($self, @argument_tokens) = @_;
149
150 # Process all function calls. That means groupings, preceded by a varialbe.
151 my @ids = grep {
152 0 ▶ $argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable') && $argument_tokens[$_+1]->isa('WWW::Shopify::Liquid::Token::Grouping')
Condition0%0/3
$argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable') && $argument_tokens[$_ + 1]->isa('WWW::Shopify::Liquid::Token::Grouping')
!ll&&!rl&&r
000
MC/DC0%0/2
$argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable') && $argument_tokens[$_ + 1]->isa('WWW::Shopify::Liquid::Token::Grouping')
$argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable') $argument_tokens[$_ + 1]->isa('WWW::Shopify::Liquid::Token::Grouping')
Truth table0%0/3
A && B
A= $argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable')B= $argument_tokens[$_ + 1]->isa('WWW::Shopify::Liquid::Token::Grouping')
ABresult
0X0
100
111
153 } (0..$#argument_tokens-1);
154 0 for (@ids) {
155 0 $argument_tokens[$_] = WWW::Shopify::Liquid::Token::FunctionCall->new($argument_tokens[$_]->{line}, pop(@{$argument_tokens[$_]->{core}}), $argument_tokens[$_], $self->parse_argument_tokens($argument_tokens[$_+1]->members));
156 0 $argument_tokens[$_+1] = undef;
157 }
158 0 @argument_tokens = grep { defined $_ } @argument_tokens;
159
160 # Process all groupings.
161 0 ($argument_tokens[$_]) = $self->parse_argument_tokens($argument_tokens[$_]->members) for (grep { $argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Grouping') } 0..$#argument_tokens);
162
163 # Process all groupings inside named variables.
164 0 ▶ ($_->{core}) = $self->parse_argument_tokens($_->{core}->members) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{core}->isa('WWW::Shopify::Liquid::Token::Grouping') } @argument_tokens);
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'core'}->isa('WWW::Shopify::Liquid::Token::Grouping')
!ll&&!rl&&r
000
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{'core'}->isa('WWW::Shopify::Liquid::Token::Grouping')
$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') $_->{'core'}->isa('WWW::Shopify::Liquid::Token::Grouping')
Truth table0%0/3
A && B
A= $_->isa('WWW::Shopify::Liquid::Token::Variable::Named')B= $_->{'core'}->isa('WWW::Shopify::Liquid::Token::Grouping')
ABresult
0X0
100
111
165 # Preprocess all variant filters.
166 0 for my $variable (grep { $_->isa('WWW::Shopify::Liquid::Token::Variable') } @argument_tokens) {
167 0 my @core = @{$variable->{core}};
168 0 ($variable->{core}->[$_]) = $self->parse_argument_tokens($core[$_]->members) for (grep { $core[$_]->isa('WWW::Shopify::Liquid::Token::Grouping') } 0..$#core);
169 }
170
171 # Every member that's a grouping inside of the hash should be evaluated.
172 0 ▶ $self->walk_groupings($_) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array') } @argument_tokens);
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array')
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array')
$_->isa('WWW::Shopify::Liquid::Token::Hash') $_->isa('WWW::Shopify::Liquid::Token::Array')
Truth table0%0/3
A || B
A= $_->isa('WWW::Shopify::Liquid::Token::Hash')B= $_->isa('WWW::Shopify::Liquid::Token::Array')
ABresult
1X1
011
000
173
174 # Process unary operators first; these have highest priority, regardless of what the priority field says.
175 0 ▶ while ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && defined $_->{core} && $self->operator($_->{core}) && $self->operator($_->{core})->arity eq "unary" } @argument_tokens) != -1) {
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"}) and $self->operator($_->{"core"})->arity eq "unary"; } , @argument_tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"}) and $self->operator($_->{"core"})->arity eq "unary" 0 0 0
Condition0%0/6
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"})
!ll&&!rl&&r
000
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"}
!ll&&!rl&&r
000
MC/DC0%0/3
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"})
$_->isa("WWW::Shopify::Liquid::Token::Operator") defined $_->{"core"} $self->operator($_->{"core"})
Truth table0%0/4
A and B and C
A= $_->isa("WWW::Shopify::Liquid::Token::Operator")B= defined $_->{"core"}C= $self->operator($_->{"core"})
ABCresult
0XX0
10X0
1100
1111
176 0 my $op = $argument_tokens[$idx];
177 0 my $fixness = $self->operator($argument_tokens[$idx]->{core})->fixness;
178 0 ▶ my $op1 = $fixness eq "postfix" ? $argument_tokens[$idx-1] : $argument_tokens[$idx+1];
Branch: 1 branch
BranchTrueFalseTotal
$fixness eq 'postfix' ? : 0 0 0
179 0 ▶ my $start = $fixness eq "potsfix" ? $idx-1 : $idx;
Branch: 1 branch
BranchTrueFalseTotal
$fixness eq 'potsfix' ? : 0 0 0
180 0 splice(@argument_tokens, $start, 2, $self->operator($argument_tokens[$idx]->{core})->new($op->{line}, $op->{core}, $op1));
181 }
182
183 # First, pull together filters. These are the highest priority operators, after parentheses. They also have their own weird syntax.
184 0 my $top = undef;
185
186 # Don't partition if we have any pipes. Pipes and multiple arguments don't play well together.
187 0 my @partitions;
188 0 my $has_pipe = 0;
189 0 ▶ if (int(grep { $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|" } @argument_tokens) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (int grep({$_->isa('WWW::Shopify::Liquid::Token::Operator') and $_->{'core'} eq '|';} @argument_tokens) == 0) { } 0 0 0
Condition0%0/3
$_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{'core'} eq '|'
!ll&&!rl&&r
000
MC/DC0%0/2
$_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{'core'} eq '|'
$_->isa('WWW::Shopify::Liquid::Token::Operator') $_->{'core'} eq '|'
Truth table0%0/3
A && B
A= $_->isa('WWW::Shopify::Liquid::Token::Operator')B= $_->{'core'} eq '|'
ABresult
0X0
100
111
190 0 my $i = 0;
191 0 $has_pipe = 1;
192 0 ▶ @partitions = part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Separator'); $i; } @argument_tokens;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_->isa("WWW::Shopify::Liquid::Token::Separator") 0 0 0
193 0 @partitions = map { my @n = grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @$_; \@n } @partitions;
194 } else {
195 0 @partitions = (\@argument_tokens);
196 }
197
198
199
200 0 my @tops;
201
202
203
204 0 foreach my $partition (@partitions) {
205 0 my @tokens = @$partition;
206 #@tokens = (grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @tokens) if !$has_pipe;
207
208 # Use the order of operations to create a binary tree structure.
209 0 foreach my $operators ($self->order_of_operations) {
210 0 my %ops = map { $_ => 1 } map { $_->symbol } @$operators;
211 # If we have pipes, we deal with those, and parse their lower level arguments first; this is an exception. Rewrite?
212 0 ▶ if ($operators->[0] eq 'WWW::Shopify::Liquid::Operator::Pipe') {
Branch: 1 branch
BranchTrueFalseTotal
if ($operators->[0] eq 'WWW::Shopify::Liquid::Operator::Pipe') { } 0 0 0
213 0 ▶ if ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|" } @tokens) != -1) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"; } , @tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|" 0 0 0
214 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser($tokens[0]) if $idx == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx == 0 0 0 0
215 0 my $i = 0;
216 # Part should consist of the first token before a pipe, and then split on all pipes after this.,
217 0 ▶ my @parts = map { shift(@{$_}) if $_->[0]->{core} && $_->[0]->{core} eq "|"; $_ } part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|"; $i; } splice(@tokens, $idx-1);
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if $_->[0]{"core"} and $_->[0]{"core"} eq "|" 0 0 0
if $_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|" 0 0 0
Condition0%0/6
$_->[0]{"core"} and $_->[0]{"core"} eq "|"
!ll&&!rl&&r
000
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"
!ll&&!rl&&r
000
MC/DC0%0/2
$_->[0]{"core"} and $_->[0]{"core"} eq "|"
$_->[0]{"core"} $_->[0]{"core"} eq "|"
MC/DC0%0/2
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"
$_->isa("WWW::Shopify::Liquid::Token::Operator") $_->{"core"} eq "|"
Truth table0%0/3
A and B
A= $_->[0]{"core"}B= $_->[0]{"core"} eq "|"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $_->isa("WWW::Shopify::Liquid::Token::Operator")B= $_->{"core"} eq "|"
ABresult
0X0
100
111
218 0 my $next = undef;
219 0 $top = $self->parse_filter_tokens($self->parse_argument_tokens(@{shift(@parts)}), @{shift(@parts)});
220 0 ▶ while (my $part = shift(@parts)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $part = shift @parts) 0 0 0
221 0 $top = $self->parse_filter_tokens($top, @$part);
222 }
223 0 push(@tokens, $top);
224 }
225 } else {
226 0 ▶ while ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && exists $ops{$_->{core}} } @tokens) != -1) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and exists $ops{$_->{"core"}}; } , @tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and exists $ops{$_->{"core"}} 0 0 0
227 0 my ($op1, $op, $op2) = @tokens[$idx-1..$idx+1];
228 # The one exception would be if we have a - operator, and nothing before, this is unary negative operator, i.e. 0 - number.
229 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Operands($op, $op1, $op, $op2) unless
Branch: 1 branch
BranchTrueFalseTotal
unless $idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter") 0 0 0
Condition0%0/21
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter")
!ll&&!rl&&r
000
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter")
!ll&&!rl&&r
000
$idx > 0 and $idx < $#tokens
!ll&&!rl&&r
000
$op1->isa("WWW::Shopify::Liquid::Operator") or $op1->isa("WWW::Shopify::Liquid::Token::Operand") or $op1->isa("WWW::Shopify::Liquid::Filter")
l!l&&r!l&&!r
000
$op1->isa("WWW::Shopify::Liquid::Operator") or $op1->isa("WWW::Shopify::Liquid::Token::Operand")
l!l&&r!l&&!r
000
$op2->isa("WWW::Shopify::Liquid::Operator") or $op2->isa("WWW::Shopify::Liquid::Token::Operand") or $op2->isa("WWW::Shopify::Liquid::Filter")
l!l&&r!l&&!r
000
$op2->isa("WWW::Shopify::Liquid::Operator") or $op2->isa("WWW::Shopify::Liquid::Token::Operand")
l!l&&r!l&&!r
000
MC/DC0%0/8
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter")
$idx > 0 $idx < $#tokens $op1->isa("WWW::Shopify::Liquid::Operator") $op1->isa("WWW::Shopify::Liquid::Token::Operand") $op1->isa("WWW::Shopify::Liquid::Filter") $op2->isa("WWW::Shopify::Liquid::Operator") $op2->isa("WWW::Shopify::Liquid::Token::Operand") $op2->isa("WWW::Shopify::Liquid::Filter")
Truth table0%0/15
A and B and C or D or E and F or G or H
A= $idx > 0B= $idx < $#tokensC= $op1->isa("WWW::Shopify::Liquid::Operator")D= $op1->isa("WWW::Shopify::Liquid::Token::Operand")E= $op1->isa("WWW::Shopify::Liquid::Filter")F= $op2->isa("WWW::Shopify::Liquid::Operator")G= $op2->isa("WWW::Shopify::Liquid::Token::Operand")H= $op2->isa("WWW::Shopify::Liquid::Filter")
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
11000XXX0
111XX0000
1101X0000
110010000
111XX1XX1
111XX01X1
111XX0011
1101X1XX1
1101X01X1
1101X0011
110011XX1
1100101X1
110010011
230 $idx > 0 && $idx < $#tokens &&
231 ($op1->isa('WWW::Shopify::Liquid::Operator') || $op1->isa('WWW::Shopify::Liquid::Token::Operand') || $op1->isa('WWW::Shopify::Liquid::Filter')) &&
232 ($op2->isa('WWW::Shopify::Liquid::Operator') || $op2->isa('WWW::Shopify::Liquid::Token::Operand') || $op2->isa('WWW::Shopify::Liquid::Filter'));
233 0 ▶ ($op1) = $self->parse_argument_tokens($op1->members) if $op1->isa('WWW::Shopify::Liquid::Token::Grouping');
Branch: 1 branch
BranchTrueFalseTotal
if $op1->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
234 0 ▶ ($op2) = $self->parse_argument_tokens($op2->members) if $op2->isa('WWW::Shopify::Liquid::Token::Grouping');
Branch: 1 branch
BranchTrueFalseTotal
if $op2->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
235 0 splice(@tokens, $idx-1, 3, $self->operators->{$op->{core}}->new($op->{line}, $op->{core}, $op1, $op2));
236 }
237 }
238 }
239
240 # Only named variables can be without commas, for whatever reason. Goddammit shopify.
241 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Operands(@tokens) unless int(grep { !$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') } @tokens) == 1 || int(grep { !$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') } @tokens) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0 0 0 0
Condition0%0/3
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
Truth table0%0/3
A or B
A= int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1B= int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
ABresult
1X1
011
000
242 0 push(@tops, @tokens);
243 }
244
245 0 return @tops;
246 }
247  
248  
249 0 ▶sub parse_inner_tokens {
Subroutine parse_inner_tokens: not called CC=28 SCAR=67.0
250 0 my ($self, @tokens) = @_;
251
252 0 ▶ return () if int(@tokens) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if int @tokens == 0 0 0 0
253
254 0 my @tags = ();
255 # First we take a look and start matching up opening and ending tags. Those which are free tags we can leave as is.
256 0 ▶ while (my $token = shift(@tokens)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @tokens) 0 0 0
257 0 my $line = $token->{line};
258 0 ▶ if ($token->isa('WWW::Shopify::Liquid::Token::Tag')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->isa('WWW::Shopify::Liquid::Token::Tag')) { } 0 0 0
elsif ($token->isa('WWW::Shopify::Liquid::Token::Output')) { } 0 0 0
259 0 my $tag = undef;
260 0 ▶ if ($self->enclosing_tags->{$token->tag}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->enclosing_tags->{$token->tag}) { } 0 0 0
elsif ($self->free_tags->{$token->tag}) { } 0 0 0
261 0 my @internal = ();
262 0 my @contents = ();
263 0 my %allowed_internal_tags = map { $_ => 1 } $self->enclosing_tags->{$token->tag}->inner_tags;
264 0 my $level = 1;
265 0 my $closed = undef;
266 0 for (0..$#tokens) {
267 0 ▶ if ($tokens[$_]->isa('WWW::Shopify::Liquid::Token::Tag')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tokens[$_]->isa("WWW::Shopify::Liquid::Token::Tag")) 0 0 0
268 0 ▶ if ($self->enclosing_tags->{$tokens[$_]->tag}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->enclosing_tags->{$tokens[$_]->tag}) { } 0 0 0
elsif (exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1) { } 0 0 0
elsif ($tokens[$_]->tag eq 'end' . $token->tag and $level == 1) { } 0 0 0
elsif ($tokens[$_]->tag =~ /^end/) { } 0 0 0
269 0 ++$level;
270 ▶ } elsif (exists $allowed_internal_tags{$tokens[$_]->tag} && $level == 1) {
Condition0%0/3
exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1
exists $allowed_internal_tags{$tokens[$_]->tag} $level == 1
Truth table0%0/3
A and B
A= exists $allowed_internal_tags{$tokens[$_]->tag}B= $level == 1
ABresult
0X0
100
111
271 0 $tokens[$_]->{arguments} = [$self->parse_argument_tokens(@{$tokens[$_]->{arguments}})];
272 0 push(@internal, $_);
273 ▶ } elsif ($tokens[$_]->tag eq "end" . $token->tag && $level == 1) {
Condition0%0/3
$tokens[$_]->tag eq 'end' . $token->tag and $level == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$tokens[$_]->tag eq 'end' . $token->tag and $level == 1
$tokens[$_]->tag eq 'end' . $token->tag $level == 1
Truth table0%0/3
A and B
A= $tokens[$_]->tag eq 'end' . $token->tagB= $level == 1
ABresult
0X0
100
111
274 0 --$level;
275 0 my $last_int = 0;
276 0 foreach my $int (@internal, $_) {
277 0 push(@contents, [splice(@tokens, 0, $int-$last_int)]);
278 0 ▶ shift(@{$contents[0]}) if $self->enclosing_tags->{$token->tag}->inner_ignore_whitespace && int(@contents) > 0 && int(@{$contents[0]}) > 0 && $contents[0]->[0]->isa('WWW::Shopify::Liquid::Token::Text::Whitespace');
Branch: 1 branch
BranchTrueFalseTotal
if $self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace") 0 0 0
Condition0%0/9
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
!ll&&!rl&&r
000
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0
!ll&&!rl&&r
000
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0
!ll&&!rl&&r
000
MC/DC0%0/4
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace int @contents > 0 int @{$contents[0];} > 0 $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
Truth table0%0/5
A and B and C and D
A= $self->enclosing_tags->{$token->tag}->inner_ignore_whitespaceB= int @contents > 0C= int @{$contents[0];} > 0D= $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
279 @contents = map {
280 0 my @array = @$_;
281 0 ▶ if (int(@array) > 0 && $array[0]->isa('WWW::Shopify::Liquid::Token::Tag') && $allowed_internal_tags{$array[0]->tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if (int @array > 0 and $array[0]->isa('WWW::Shopify::Liquid::Token::Tag') and $allowed_internal_tags{$array[0]->tag}) { } 0 0 0
Condition0%0/6
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") and $allowed_internal_tags{$array[0]->tag}
!ll&&!rl&&r
000
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag")
!ll&&!rl&&r
000
MC/DC0%0/3
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") and $allowed_internal_tags{$array[0]->tag}
int @array > 0 $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") $allowed_internal_tags{$array[0]->tag}
Truth table0%0/4
A and B and C
A= int @array > 0B= $array[0]->isa("WWW::Shopify::Liquid::Token::Tag")C= $allowed_internal_tags{$array[0]->tag}
ABCresult
0XX0
10X0
1100
1111
282 0 [$array[0], $self->parse_inner_tokens(@array[1..$#array])];
283 }
284 else {
285 0 [$self->parse_inner_tokens(@array)]
286 }
287 } @contents;
288 0 $last_int = $int;
289 }
290 # Remove the endtag.
291 0 shift(@tokens);
292 0 $closed = 1;
293 0 last;
294 } elsif ($tokens[$_]->tag =~ m/^end/) {
295 0 --$level;
296 # TODO: Fix this whole thing; right now, no close tags are being spit out for the wrong tag. We do this to avoid an {% unless %}{% if %}{% else %}{% endif %}{% endunless%} situtation.
297 }
298 }
299 }
300 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NoClose($token) unless $closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $closed 0 0 0
301 0 $tag = $self->enclosing_tags->{$token->tag}->new($line, $token->tag, [$self->parse_argument_tokens(@{$token->{arguments}})], \@contents, $self);
302 0 $tag->verify($self);
303 }
304 elsif ($self->free_tags->{$token->tag}) {
305 0 $tag = $self->free_tags->{$token->tag}->new($line, $token->tag, [$self->parse_argument_tokens(@{$token->{arguments}})], undef, $self);
306 0 $tag->verify($self);
307 }
308 else {
309 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NoOpen($token) if ($token->tag =~ m/^end(\w+)$/ && $self->enclosing_tags->{$1});
Branch: 1 branch
BranchTrueFalseTotal
if $token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1} 0 0 0
Condition0%0/3
$token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1}
!ll&&!rl&&r
000
MC/DC0%0/2
$token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1}
$token->tag =~ /^end(\w+)$/ $self->enclosing_tags->{$1}
Truth table0%0/3
A and B
A= $token->tag =~ /^end(\w+)$/B= $self->enclosing_tags->{$1}
ABresult
0X0
100
111
310 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NakedInnerTag($token) if (exists $self->inner_tags->{$token->tag});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->inner_tags->{$token->tag} 0 0 0
311 0 die new WWW::Shopify::Liquid::Exception::Parser::UnknownTag($token);
312 }
313 0 push(@tags, $tag);
314 }
315 elsif ($token->isa('WWW::Shopify::Liquid::Token::Output')) {
316 0 push(@tags, WWW::Shopify::Liquid::Tag::Output->new($line, [$self->parse_argument_tokens(@{$token->{core}})]));
317 }
318 else {
319 0 push(@tags, $token);
320 }
321 }
322
323 0 my $top = undef;
324 0 ▶ if (int(@tags) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (int @tags > 1) { } 0 0 0
325 0 $top = WWW::Shopify::Liquid::Operator::Concatenate->new($tags[0]->{line}, '', @tags);
326 }
327 else {
328 0 ($top) = @tags;
329 }
330 0 return $top;
331 }
332  
333 0 ▶sub parse_tokens {
Subroutine parse_tokens: not called CC=4 SCAR=30.0
334 0 my ($self, @tokens) = @_;
335 0 my $ast = $self->parse_inner_tokens(@tokens);
336 0 for (@{$self->{transient_elements}}) {
337 0 ▶ if ($_->isa('WWW::Shopify::Liquid::Tag')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->isa('WWW::Shopify::Liquid::Tag')) { } 0 0 0
elsif ($_->isa('WWW::Shopify::Liquid::Filter')) { } 0 0 0
338 0 $self->deregister_tag($_);
339 } elsif ($_->isa('WWW::Shopify::Liquid::Filter')) {
340 0 $self->deregister_filter($_);
341 }
342 }
343 0 $self->{transient_elements} = [];
344 0 return $ast;
345 }
346  
347 0 ▶sub unparse_argument_tokens {
Subroutine unparse_argument_tokens: not called CC=8 SCAR=42.8
348 0 my ($self, $ast) = @_;
349 0 ▶ return $ast if $self->is_processed($ast);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_processed($ast) 0 0 0
350 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Filter')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Filter')) { } 0 0 0
elsif ($ast->isa('WWW::Shopify::Liquid::Operator')) { } 0 0 0
351 my @optokens = ($self->unparse_argument_tokens($ast->{operand}),
352 WWW::Shopify::Liquid::Token::Operator->new([0,0,0], '|'),
353 ($ast->transparent ? WWW::Shopify::Liquid::Token::Variable->new([0,0,0], WWW::Shopify::Liquid::Token::String->new([0,0,0], $ast->{core}->name)) : WWW::Shopify::Liquid::Token::Variable->new([0,0,0], WWW::Shopify::Liquid::Token::String->new([0,0,0], $ast->{core}))),
354 0 ▶ (int(@{$ast->{arguments}}) > 0 ? (do {
Branch: 2 branches
BranchTrueFalseTotal
$ast->transparent ? : 0 0 0
int @{$ast->{'arguments'};} > 0 ? : 0 0 0
355 0 my @args = @{$ast->{arguments}};
356 (
357 WWW::Shopify::Liquid::Token::Separator->new([0,0,0], ':'),
358 0 ▶ (map { (($_ > 0 ? (WWW::Shopify::Liquid::Token::Separator->new([0,0,0], ',')) : ()), $self->unparse_argument_tokens($args[$_])) } 0..$#args)
Branch: 1 branch
BranchTrueFalseTotal
$_ > 0 ? : 0 0 0
359 )
360 }) : ())
361 );
362 0 return @optokens;
363 } elsif ($ast->isa('WWW::Shopify::Liquid::Operator')) {
364 0 my @optokens = ($self->unparse_argument_tokens($ast->{operands}->[0]), WWW::Shopify::Liquid::Token::Operator->new([0,0,0], $ast->{core}), $self->unparse_argument_tokens($ast->{operands}->[1]));
365 0 ▶ return WWW::Shopify::Liquid::Token::Grouping->new([0,0,0], @optokens) if $ast->requires_grouping;
Branch: 1 branch
BranchTrueFalseTotal
if $ast->requires_grouping 0 0 0
366 0 return @optokens;
367 } else {
368 0 return $ast;
369 }
370 }
371  
372 38 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
373 0 ▶sub unparse_tokens {
Subroutine unparse_tokens: not called CC=13 SCAR=52.0
374 0 my ($self, $ast) = @_;
375 0 ▶ return $ast if $self->is_processed($ast) || $ast->isa('WWW::Shopify::Liquid::Token');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token") 0 0 0
Condition0%0/3
$self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token")
$self->is_processed($ast) $ast->isa("WWW::Shopify::Liquid::Token")
Truth table0%0/3
A or B
A= $self->is_processed($ast)B= $ast->isa("WWW::Shopify::Liquid::Token")
ABresult
1X1
011
000
376 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa("WWW::Shopify::Liquid::Tag")) 0 0 0
377 0 ▶ my @arguments = $ast->{arguments} ? $self->unparse_argument_tokens(@{$ast->{arguments}}) : ();
Branch: 1 branch
BranchTrueFalseTotal
$ast->{'arguments'} ? : 0 0 0
378 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag::Enclosing')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Tag::Enclosing')) { } 0 0 0
elsif ($ast->isa('WWW::Shopify::Liquid::Tag::Output')) { } 0 0 0
379 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Tag::If')) { } 0 0 0
380 0 ▶ return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end' . $ast->{core})) if !$ast->{false_path};
Branch: 1 branch
BranchTrueFalseTotal
unless $ast->{"false_path"} 0 0 0
381 0 ▶ if (blessed($ast->{false_path}) && $ast->{false_path}->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($ast->{"false_path"}) and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")) 0 0 0
Condition0%0/3
builtin::blessed($ast->{"false_path"}) and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($ast->{"false_path"}) and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
builtin::blessed($ast->{"false_path"}) $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
Truth table0%0/3
A and B
A= builtin::blessed($ast->{"false_path"})B= $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
ABresult
0X0
100
111
382 # Untangle the thing, and spread out in an array all if statement that have if statements as their false_paths.
383 0 my @elsifs;
384 my $recursive;
385 0 ▶ $recursive = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
386 0 my ($ast) = @_;
387 0 ▶ push(@elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'elsif', ($ast->{arguments} ? [$self->unparse_argument_tokens(@{$ast->{arguments}})] : [])), $self->unparse_tokens($ast->{true_path}));
Branch: 1 branch
BranchTrueFalseTotal
$ast->{'arguments'} ? : 0 0 0
388 0 ▶ if ($ast->{false_path} && $ast->{false_path}->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->{'false_path'} and $ast->{'false_path'}->isa('WWW::Shopify::Liquid::Tag::If')) { } 0 0 0
elsif ($ast->{'false_path'}) { } 0 0 0
Condition0%0/3
$ast->{"false_path"} and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
!ll&&!rl&&r
000
MC/DC0%0/2
$ast->{"false_path"} and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
$ast->{"false_path"} $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
Truth table0%0/3
A and B
A= $ast->{"false_path"}B= $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
ABresult
0X0
100
111
389 0 $recursive->($ast->{false_path});
390 } elsif ($ast->{false_path}) {
391 0 push(@elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'else'), $self->unparse_tokens($ast->{false_path}));
392 }
393 0 };
394 0 $recursive->($ast->{false_path});
395 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), @elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end'. $ast->{core}));
396 }
397 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'else'), $self->unparse_tokens($ast->{false_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end'. $ast->{core}));
398 }
399 else {
400 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{contents}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end' . $ast->{core}));
401 }
402 }
403 elsif ($ast->isa('WWW::Shopify::Liquid::Tag::Output')) {
404 0 return (WWW::Shopify::Liquid::Token::Output->new([0,0,0], [$self->unparse_argument_tokens(@{$ast->{arguments}})]));
405 }
406 else {
407 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments));
408 }
409 0 return $ast;
410 }
411 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Filter')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa("WWW::Shopify::Liquid::Filter")) 0 0 0
412 0 return $ast;
413 }
414 0 ▶ return (map { $self->unparse_tokens($_) } @{$ast->{operands}}) if ($ast->isa('WWW::Shopify::Liquid::Operator::Concatenate'));
Branch: 1 branch
BranchTrueFalseTotal
if $ast->isa("WWW::Shopify::Liquid::Operator::Concatenate") 0 0 0
415
416 }
417  
418 1;
« lib/WWW/Shopify/Liquid/Tag/Assign.pm ↑ Summary lib/WWW/Shopify/Liquid/Tag/For.pm »