X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FCompletionDriver%2FINC.pm;h=0daf803ab5ec3adf0f270b90219802eb8fa66a70;hp=0166c8c1543f70cfe0dbcac8fed6a6852c5ed659;hb=ce00c3c0a40bb8b788d36d85bdbba43d05523b9a;hpb=c5cdacc287ddd3f003feec2c473f1661d4bb317f diff --git a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm index 0166c8c..0daf803 100644 --- a/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm +++ b/lib/Devel/REPL/Plugin/CompletionDriver/INC.pm @@ -4,6 +4,11 @@ use File::Next; use File::Spec; use namespace::clean -except => [ 'meta' ]; +sub BEFORE_PLUGIN { + my $self = shift; + $self->load_plugin('Completion'); +} + around complete => sub { my $orig = shift; my ($self, $text, $document) = @_; @@ -57,6 +62,9 @@ around complete => sub { my @found; + # most VCSes don't litter every single fucking directory with garbage. if you + # know of any other, just stick them in here. noone wants to complete + # Devel::REPL::Plugin::.svn my %ignored = ( '.' => 1, @@ -64,10 +72,11 @@ around complete => sub { '.svn' => 1, ); + # this will take a directory and add to @found all of the possible matches my $add_recursively; $add_recursively = sub { my ($path, $iteration, @more) = @_; - opendir((my $dirhandle), $path); + opendir((my $dirhandle), $path) || return; for (grep { !$ignored{$_} } readdir $dirhandle) { my $match = $_; @@ -90,9 +99,13 @@ around complete => sub { } }; + # look through all of INC: for (@INC) { my $path = $_; + + # match all of the fragments they have, so "use Moose::Meta::At" + # will only begin looking in ../Moose/Meta/ for my $subdir (@directories) { $path = File::Spec->catdir($path, $subdir); @@ -107,3 +120,15 @@ around complete => sub { 1; +__END__ + +=head1 NAME + +Devel::REPL::Plugin::CompletionDriver::INC - Complete module names in use and require + +=head1 AUTHOR + +Shawn M Moore, C<< >> + +=cut +