Devel::PerlySense::Document::Location - A file name + cursor position


Devel-PerlySense documentation Contained in the Devel-PerlySense distribution.

Index


Code Index:

NAME

Top

Devel::PerlySense::Document::Location - A file name + cursor position

SYNOPSIS

Top

DESCRIPTION

Top

A location describes a cursor position (optional) in a file, and optional properties.

PROPERTIES

Top

file

Default: ""

row

The row (0..) of the location. The actual rows are 1.., 0 means N/A.

Default: 0

col

The col (0..) of the location. The actual cols are 1.., 0 means N/A.

Default: 0

rhProperty

Hash ref with (names: name of payload, keys: some payload).

A generic container for whatever things may be attached to this location, like POD text, a PPI::Node, a type string or whatever.

Default: {}

API METHODS

Top

new(file => $file, row => $row, col => $col)

Create new Location object.

clone()

Return clone of this object.

Die on errors.

rhInfo()

Return a hash ref with the complete attributes of the class, i.e. both the file and the properties in rhProperty.

AUTHOR

Top

Johan Lindström, <johanl[ÄT]DarSerMan.com>

BUGS

Top

Please report any bugs or feature requests to bug-devel-perlysense@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Devel-PerlySense documentation Contained in the Devel-PerlySense distribution.




use strict;
use warnings;

package Devel::PerlySense::Document::Location;
our $VERSION = '0.01';





use Spiffy -Base;
use Carp;
use Data::Dumper;
use Storable "dclone";
use PPI;
use File::Slurp;





field "file" => "";



field "row";





field "col";





field "rhProperty" => {};





sub new(@) {
    my $pkg = shift;
    my (%p) = @_;

    my $self = bless {}, $pkg;

    $self->file($p{file} || "");
    $self->row($p{row} || 0);
    $self->col($p{col} || 0);
    $self->rhProperty($p{rhProperty} || {});

    return($self);    
}





sub clone {
    return(dclone($self));
}





sub rhInfo {
    my $rhInfo = dclone($self->rhProperty);
    for my $field (qw/ file row col /) {
        $rhInfo->{$field} = $self->$field;
    }
    
    return($rhInfo);
}





1;





__END__