File Coverage

blib/lib/PPIx/QuoteLike/Token.pm
Criterion Covered Total %
statement 49 57 85.9
branch 10 16 62.5
condition 1 3 33.3
subroutine 19 21 90.4
pod 13 13 100.0
total 92 110 83.6


line stmt bran cond sub pod time code
1             package PPIx::QuoteLike::Token;
2              
3 7     7   808 use 5.006;
  7         21  
4              
5 7     7   30 use strict;
  7         44  
  7         144  
6 7     7   53 use warnings;
  7         19  
  7         185  
7              
8 7     7   46 use Carp;
  7         14  
  7         352  
9 7     7   37 use PPIx::QuoteLike::Constant qw{ MINIMUM_PERL @CARP_NOT };
  7         10  
  7         545  
10 7         3369 use PPIx::QuoteLike::Utils qw{
11             column_number
12             line_number
13             logical_filename
14             logical_line_number
15             statement
16             visual_column_number
17 7     7   1973 };
  7         14  
18              
19             our $VERSION = '0.022';
20              
21             # Private to this package.
22             sub __new {
23 324     324   4434 my ( $self, %arg ) = @_;
24             defined $arg{content}
25 324 50       604 or croak 'Content required';
26 324   33     1025 return bless \%arg, ref $self || $self;
27             }
28              
29             sub content {
30 548     548 1 12711 my ( $self ) = @_;
31 548         1778 return $self->{content};
32             }
33              
34             sub error {
35 46     46 1 86 my ( $self ) = @_;
36 46         192 return $self->{error};
37             }
38              
39             sub location {
40 27     27 1 901 my ( $self ) = @_;
41 27 50       52 return $self->{location} ? [ @{ $self->{location} } ] : undef;
  27         152  
42             }
43              
44             sub parent {
45 47     47 1 84 my ( $self ) = @_;
46 47         193 return $self->{parent};
47             }
48              
49             sub next_sibling {
50 46     46 1 84 my ( $self ) = @_;
51             $self->{next_sibling}
52 46 100       112 or return;
53 21         36 return $self->{next_sibling};
54             }
55              
56             sub perl_version_introduced {
57 80     80 1 137 my ( $self ) = @_;
58             # TODO use '//' when we can require Perl 5.10.
59             defined $self->{perl_version_introduced}
60 80 100       163 and return $self->{perl_version_introduced};
61 65         175 my $vers = $self->__perl_version_introduced();
62 65 100       118 defined $vers
63             or $vers = MINIMUM_PERL;
64 65         148 return ( $self->{perl_version_introduced} = $vers );
65             }
66              
67             sub __perl_version_introduced {
68 44     44   64 return;
69             }
70              
71             sub perl_version_removed {
72 62     62 1 140 return undef; ## no critic (ProhibitExplicitReturnUndef)
73             }
74              
75             sub previous_sibling {
76 46     46 1 86 my ( $self ) = @_;
77             $self->{previous_sibling}
78 46 100       115 or return;
79 20         38 return $self->{previous_sibling};
80             }
81              
82             sub significant {
83 21     21 1 50 return 1;
84             }
85              
86             sub snext_sibling {
87 0     0 1 0 my ( $sib ) = @_;
88 0         0 while ( $sib = $sib->next_sibling() ) {
89 0 0       0 $sib->significant()
90             and return $sib;
91             }
92 0         0 return;
93             }
94              
95             sub sprevious_sibling {
96 0     0 1 0 my ( $sib ) = @_;
97 0         0 while ( $sib = $sib->previous_sibling() ) {
98 0 0       0 $sib->significant()
99             and return $sib;
100             }
101 0         0 return;
102             }
103              
104             sub top {
105 1     1 1 2 my ( $self ) = @_;
106 1         2 my $kid = $self;
107 1         5 while ( defined ( my $parent = $kid->parent() ) ) {
108 1         5 $kid = $parent;
109             }
110 1         3 return $kid;
111             }
112              
113             sub variables {
114 45     45 1 96 return;
115             }
116              
117             1;
118              
119             __END__