1 #####################################################################
3 # The Perl::Tidy::LineBuffer class supplies a 'get_line()'
4 # method for returning the next line to be parsed, as well as a
5 # 'peek_ahead()' method
7 # The input parameter is an object with a 'get_line()' method
8 # which returns the next line to be parsed
10 #####################################################################
12 package Perl::Tidy::LineBuffer;
15 our $VERSION = '20200110';
19 my ( $class, $line_source_object ) = @_;
22 _line_source_object => $line_source_object,
23 _rlookahead_buffer => [],
28 my ( $self, $buffer_index ) = @_;
30 my $line_source_object = $self->{_line_source_object};
31 my $rlookahead_buffer = $self->{_rlookahead_buffer};
32 if ( $buffer_index < scalar( @{$rlookahead_buffer} ) ) {
33 $line = $rlookahead_buffer->[$buffer_index];
36 $line = $line_source_object->get_line();
37 push( @{$rlookahead_buffer}, $line );
45 my $line_source_object = $self->{_line_source_object};
46 my $rlookahead_buffer = $self->{_rlookahead_buffer};
48 if ( scalar( @{$rlookahead_buffer} ) ) {
49 $line = shift @{$rlookahead_buffer};
52 $line = $line_source_object->get_line();