1use strict; 2use warnings; 3package Devel::REPL::Plugin::CompletionDriver::Keywords; 4# ABSTRACT: Complete Perl keywords and operators 5 6our $VERSION = '1.003028'; 7 8use Devel::REPL::Plugin; 9use Devel::REPL::Plugin::Completion; # die early if cannot load 10use B::Keywords qw/@Functions @Barewords/; 11use namespace::autoclean; 12 13sub BEFORE_PLUGIN { 14 my $self = shift; 15 $self->load_plugin('Completion'); 16} 17 18around complete => sub { 19 my $orig = shift; 20 my ($self, $text, $document) = @_; 21 22 my $last = $self->last_ppi_element($document); 23 24 return $orig->(@_) 25 unless $last->isa('PPI::Token::Word'); 26 27 # don't complete keywords on foo->method 28 return $orig->(@_) 29 if $last->sprevious_sibling 30 && $last->sprevious_sibling->isa('PPI::Token::Operator') 31 && $last->sprevious_sibling->content eq '->'; 32 33 my $re = qr/^\Q$last/; 34 35 return $orig->(@_), 36 grep { $_ =~ $re } @Functions, @Barewords; 37}; 38 391; 40 41__END__ 42 43=pod 44 45=encoding UTF-8 46 47=head1 NAME 48 49Devel::REPL::Plugin::CompletionDriver::Keywords - Complete Perl keywords and operators 50 51=head1 VERSION 52 53version 1.003028 54 55=head1 SUPPORT 56 57Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> 58(or L<bug-Devel-REPL@rt.cpan.org|mailto:bug-Devel-REPL@rt.cpan.org>). 59 60There is also an irc channel available for users of this distribution, at 61L<C<#devel> on C<irc.perl.org>|irc://irc.perl.org/#devel-repl>. 62 63=head1 AUTHOR 64 65Shawn M Moore, C<< <sartak at gmail dot com> >> 66 67=head1 COPYRIGHT AND LICENCE 68 69This software is copyright (c) 2007 by Matt S Trout - mst (at) shadowcatsystems.co.uk (L<http://www.shadowcatsystems.co.uk/>). 70 71This is free software; you can redistribute it and/or modify it under 72the same terms as the Perl 5 programming language system itself. 73 74=cut 75