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 --- lib/Reply/Plugin/Autocomplete/Methods.pm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'lib') 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