| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | =head1 NAME | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | Devel::PerlySense::Document::Location - A file name + cursor position | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | A location describes a cursor position (optional) in a file, and | 
| 13 |  |  |  |  |  |  | optional properties. | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =cut | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 63 |  |  | 63 |  | 213 | use strict; | 
|  | 63 |  |  |  |  | 77 |  | 
|  | 63 |  |  |  |  | 2375 |  | 
| 22 | 63 |  |  | 63 |  | 251 | use warnings; | 
|  | 63 |  |  |  |  | 79 |  | 
|  | 63 |  |  |  |  | 1443 |  | 
| 23 | 63 |  |  | 63 |  | 613 | use utf8; | 
|  | 63 |  |  |  |  | 81 |  | 
|  | 63 |  |  |  |  | 282 |  | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | package Devel::PerlySense::Document::Location; | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 63 |  |  | 63 |  | 2716 | use Spiffy -Base; | 
|  | 63 |  |  |  |  | 4892 |  | 
|  | 63 |  |  |  |  | 352 |  | 
| 32 | 63 |  |  | 63 |  | 43322 | use Carp; | 
|  | 63 |  |  | 63 |  | 86 |  | 
|  | 63 |  |  | 63 |  | 1345 |  | 
|  | 63 |  |  |  |  | 212 |  | 
|  | 63 |  |  |  |  | 76 |  | 
|  | 63 |  |  |  |  | 1553 |  | 
|  | 63 |  |  |  |  | 221 |  | 
|  | 63 |  |  |  |  | 80 |  | 
|  | 63 |  |  |  |  | 4004 |  | 
| 33 | 63 |  |  | 63 |  | 258 | use Data::Dumper; | 
|  | 63 |  |  |  |  | 96 |  | 
|  | 63 |  |  |  |  | 4515 |  | 
| 34 | 63 |  |  | 63 |  | 702 | use Storable "dclone"; | 
|  | 63 |  |  |  |  | 3465 |  | 
|  | 63 |  |  |  |  | 2495 |  | 
| 35 | 63 |  |  | 63 |  | 586 | use PPI; | 
|  | 63 |  |  |  |  | 82834 |  | 
|  | 63 |  |  |  |  | 1048 |  | 
| 36 | 63 |  |  | 63 |  | 747 | use File::Slurp; | 
|  | 63 |  |  |  |  | 20832 |  | 
|  | 63 |  |  |  |  | 19937 |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | =head1 PROPERTIES | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =head2 file | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | Default: "" | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =cut | 
| 49 |  |  |  |  |  |  | field "file" => ""; | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =head2 row | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | The row (0..) of the location. The actual rows are 1.., 0 means N/A. | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | Default: 0 | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =cut | 
| 60 |  |  |  |  |  |  | field "row"; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =head2 col | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | The col (0..) of the location. The actual cols are 1.., 0 means N/A. | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | Default: 0 | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =cut | 
| 73 |  |  |  |  |  |  | field "col"; | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head2 rhProperty | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | Hash ref with (names: name of payload, keys: some payload). | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | A generic container for whatever things may be attached to this | 
| 84 |  |  |  |  |  |  | location, like POD text, a PPI::Node, a type string or whatever. | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | Default: {} | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =cut | 
| 89 |  |  |  |  |  |  | field "rhProperty" => {}; | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =head1 API METHODS | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =head2 new(file => $file, row => $row, col => $col) | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | Create new Location object. | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | =cut | 
| 102 |  |  |  |  |  |  | sub new(@) { | 
| 103 | 14532 |  |  | 14532 | 1 | 235146 | my $pkg = shift; | 
| 104 | 14532 |  |  |  |  | 35626 | my (%p) = @_; | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 14532 |  |  |  |  | 46431 | my $self = bless {}, $pkg; | 
| 107 |  |  |  |  |  |  |  | 
| 108 | 14532 |  | 100 |  |  | 402904 | $self->file($p{file} || ""); | 
| 109 | 14532 |  | 100 |  |  | 510031 | $self->row($p{row} || 0); | 
| 110 | 14532 |  | 100 |  |  | 546301 | $self->col($p{col} || 0); | 
| 111 | 14532 |  | 50 |  |  | 468462 | $self->rhProperty($p{rhProperty} || {}); | 
| 112 |  |  |  |  |  |  |  | 
| 113 | 14532 |  |  |  |  | 129521 | return($self); | 
| 114 |  |  |  |  |  |  | } | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head2 clone() | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Return clone of this object. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | Die on errors. | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =cut | 
| 127 | 90 |  |  | 90 | 1 | 127 | sub clone { | 
| 128 | 90 |  |  |  |  | 10917 | return(dclone($self)); | 
| 129 |  |  |  |  |  |  | } | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head2 rhInfo() | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | Return a hash ref with the complete attributes of the class, i.e. both | 
| 138 |  |  |  |  |  |  | the file and the properties in rhProperty. | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | =cut | 
| 141 | 2 |  |  | 2 | 1 | 3 | sub rhInfo { | 
| 142 | 2 |  |  |  |  | 48 | my $rhInfo = dclone($self->rhProperty); | 
| 143 | 2 |  |  |  |  | 36 | for my $field (qw/ file row col /) { | 
| 144 | 6 |  |  |  |  | 162 | $rhInfo->{$field} = $self->$field; | 
| 145 |  |  |  |  |  |  | } | 
| 146 |  |  |  |  |  |  |  | 
| 147 | 2 |  |  |  |  | 17 | return($rhInfo); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | 1; | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | __END__ | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | =encoding utf8 | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | =head1 AUTHOR | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | Johan Lindström, C<< <johanl[ÄT]DarSerMan.com> >> | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | =head1 BUGS | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | Please report any bugs or feature requests to | 
| 171 |  |  |  |  |  |  | C<bug-devel-perlysense@rt.cpan.org>, or through the web interface at | 
| 172 |  |  |  |  |  |  | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense>. | 
| 173 |  |  |  |  |  |  | I will be notified, and then you'll automatically be notified of progress on | 
| 174 |  |  |  |  |  |  | your bug as I make changes. | 
| 175 |  |  |  |  |  |  |  | 
| 176 |  |  |  |  |  |  | =head1 ACKNOWLEDGEMENTS | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | Copyright 2005 Johan Lindström, All Rights Reserved. | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 183 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | =cut |