Acme-PlayCode

 view release on metacpan or  search on metacpan

lib/Acme/PlayCode/Plugin/ExchangeCondition.pm  view on Meta::CPAN

                    not $next_tokens[0]->interpolations ) {
                    $exchange_able = 1;
                }
                if ( $exchange_able ) {
                    # remove previous full tokens
                    my $previous_num = scalar @previous_full_tokens;
                    my $next_num     = scalar @next_full_tokens;
                    my @output = @{ $self->output };
                    @output = splice( @output, 0, scalar @output - $previous_num );
                    
                    # exchange starts
                    my @tokens_to_exchange = ( @previous_full_tokens, $token, @next_full_tokens );
                    
                    # find the place of previous_tokens and next_tokens
                    my $prev_place = firstidx { $_ eq $previous_tokens[0] } @tokens_to_exchange;
                    my $next_place = firstidx { $_ eq $next_tokens[0] } @tokens_to_exchange;
                    
                    $tokens_to_exchange[ $prev_place ] = $next_tokens[0];
                    $tokens_to_exchange[ $next_place ] = $previous_tokens[0];

                    foreach my $_token ( @tokens_to_exchange ) {

lib/Acme/PlayCode/Plugin/PrintComma.pm  view on Meta::CPAN

package Acme::PlayCode::Plugin::PrintComma;

use Moose::Role;

our $VERSION   = '0.10';
our $AUTHORITY = 'cpan:FAYLAND';

use vars qw/$printcomma_start/;

around 'do_with_token' => sub {
    my $orig = shift;
    my $self = shift;
    my ( $token ) = @_;

    my $token_flag = $self->token_flag;
    my @tokens = $self->tokens;

    $printcomma_start = 0 unless ( defined $printcomma_start );

    if ( $token->isa('PPI::Token::Word') and $token->content eq 'print' ) {
        $printcomma_start = 1;
    } elsif ( $token->isa('PPI::Token::Structure') ) {
        $printcomma_start = 0;
    } elsif ( $printcomma_start and $token->isa('PPI::Token::Operator')
        and $token->content eq '.' ) {
        if ( $tokens[$token_flag - 1]->isa('PPI::Token::Whitespace') ) {
            $self->output->[-1] = 'Acme::PlayCode::!@#$%^&*()_+';
        }
        return ',';
    }
    
    $orig->($self, @_);
};



( run in 0.325 second using v1.01-cache-2.11-cpan-0d8aa00de5b )