"Fossies" - the Fresh Open Source Software Archive

Member "Perl-Tidy-20200110/lib/Perl/Tidy/VerticalAligner/Alignment.pm" (7 Jan 2020, 3354 Bytes) of package /linux/misc/Perl-Tidy-20200110.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Alignment.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 20191203_vs_20200110.

    1 #####################################################################
    2 #
    3 # the Perl::Tidy::VerticalAligner::Alignment class holds information
    4 # on a single column being aligned
    5 #
    6 #####################################################################
    7 package Perl::Tidy::VerticalAligner::Alignment;
    8 use strict;
    9 use warnings;
   10 our $VERSION = '20200110';
   11 
   12 {
   13 
   14     #use Carp;
   15 
   16     #    _column          # the current column number
   17     #    _starting_column # column number when created
   18     #    _matching_token  # what token we are matching
   19     #    _starting_line   # the line index of creation
   20     #    _ending_line
   21     # the most recent line to use it
   22     #    _saved_column
   23     #    _serial_number   # unique number for this alignment
   24 
   25     my %default_data = (
   26         column          => undef,
   27         starting_column => undef,
   28         matching_token  => undef,
   29         starting_line   => undef,
   30         ending_line     => undef,
   31         saved_column    => undef,
   32         serial_number   => undef,
   33     );
   34 
   35     # class population count
   36     {
   37         my $_count = 0;
   38         sub get_count        { return $_count }
   39         sub _increment_count { return ++$_count }
   40         sub _decrement_count { return --$_count }
   41     }
   42 
   43     # constructor
   44     sub new {
   45         my ( $caller, %arg ) = @_;
   46         my $caller_is_obj = ref($caller);
   47         my $class         = $caller_is_obj || $caller;
   48         ##no strict "refs";
   49         my $self = bless {}, $class;
   50 
   51         foreach my $key ( keys %default_data ) {
   52             my $_key = '_' . $key;
   53             if    ( exists $arg{$key} ) { $self->{$_key} = $arg{$key} }
   54             elsif ($caller_is_obj)      { $self->{$_key} = $caller->{$_key} }
   55             else { $self->{$_key} = $default_data{$_key} }
   56         }
   57         $self->_increment_count();
   58         return $self;
   59     }
   60 
   61     sub DESTROY {
   62         my $self = shift;
   63         $self->_decrement_count();
   64         return;
   65     }
   66 
   67     sub get_column { my $self = shift; return $self->{_column} }
   68 
   69     sub get_starting_column {
   70         my $self = shift;
   71         return $self->{_starting_column};
   72     }
   73     sub get_matching_token { my $self = shift; return $self->{_matching_token} }
   74     sub get_starting_line  { my $self = shift; return $self->{_starting_line} }
   75     sub get_ending_line    { my $self = shift; return $self->{_ending_line} }
   76     sub get_serial_number  { my $self = shift; return $self->{_serial_number} }
   77 
   78     sub set_column { my ( $self, $val ) = @_; $self->{_column} = $val; return }
   79 
   80     sub set_starting_column {
   81         my ( $self, $val ) = @_;
   82         $self->{_starting_column} = $val;
   83         return;
   84     }
   85 
   86     sub set_matching_token {
   87         my ( $self, $val ) = @_;
   88         $self->{_matching_token} = $val;
   89         return;
   90     }
   91 
   92     sub set_starting_line {
   93         my ( $self, $val ) = @_;
   94         $self->{_starting_line} = $val;
   95         return;
   96     }
   97 
   98     sub set_ending_line {
   99         my ( $self, $val ) = @_;
  100         $self->{_ending_line} = $val;
  101         return;
  102     }
  103 
  104     sub increment_column {
  105         my ( $self, $val ) = @_;
  106         $self->{_column} += $val;
  107         return;
  108     }
  109 
  110     sub save_column {
  111         my $self = shift;
  112         $self->{_saved_column} = $self->{_column};
  113         return;
  114     }
  115 
  116     sub restore_column {
  117         my $self = shift;
  118         $self->{_column} = $self->{_saved_column};
  119         return;
  120     }
  121 }
  122 
  123 1;