From dc7920a0e6cb26d24b1d943f42f47e1b115192b1 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 1 Jul 2013 21:29:24 -0400 Subject: handle inherited methods --- dist.ini | 2 ++ lib/Reply/Plugin/Autocomplete/Methods.pm | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dist.ini b/dist.ini index 60c004d..df27ef6 100644 --- a/dist.ini +++ b/dist.ini @@ -29,6 +29,7 @@ skip = ^Proc::InvokeEditor$ skip = ^Win32::Console::ANSI$ skip = ^B::Keywords$ skip = ^Package::Stash$ +skip = ^MRO::Compat$ [Prereqs / RuntimeRecommends] App::Nopaste = 0 @@ -39,6 +40,7 @@ Proc::InvokeEditor = 0 Term::ReadLine::Gnu = 0 B::Keywords = 0 Package::Stash = 0 +MRO::Compat = 0 ; XXX it'd be nice if we could make this recommended instead of required [OSPrereqs / MSWin32] diff --git a/lib/Reply/Plugin/Autocomplete/Methods.pm b/lib/Reply/Plugin/Autocomplete/Methods.pm index cd54d31..93fda29 100644 --- a/lib/Reply/Plugin/Autocomplete/Methods.pm +++ b/lib/Reply/Plugin/Autocomplete/Methods.pm @@ -5,6 +5,7 @@ use warnings; use base 'Reply::Plugin'; +use MRO::Compat; use Package::Stash; use Scalar::Util 'blessed'; @@ -54,7 +55,7 @@ sub tab_handler { $method = '' unless defined $method; - my $package; + my $class; if ($invocant =~ /^\$/) { my $env = { (map { %$_ } values %{ $self->{env} }), @@ -62,23 +63,25 @@ sub tab_handler { }; my $var = $env->{$invocant}; return unless $var && ref($var) eq 'REF' && blessed($$var); - $package = blessed($$var); + $class = blessed($$var); } else { - $package = $invocant; + $class = $invocant; } - my $stash = eval { Package::Stash->new($package) }; - return unless $stash; - my @results; - for my $stash_method ($stash->list_all_symbols('CODE')) { - next unless index($stash_method, $method) == 0; + for my $package (@{ mro::get_linear_isa($class) }) { + my $stash = eval { Package::Stash->new($package) }; + next unless $stash; + + for my $stash_method ($stash->list_all_symbols('CODE')) { + next unless index($stash_method, $method) == 0; - push @results, $stash_method; + push @results, $stash_method; + } } - return @results; + return sort @results; } 1; -- cgit v1.2.3-54-g00ecf