summaryrefslogtreecommitdiffstats
path: root/lib/Reply/Plugin/Autocomplete/Methods.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reply/Plugin/Autocomplete/Methods.pm')
-rw-r--r--lib/Reply/Plugin/Autocomplete/Methods.pm63
1 files changed, 31 insertions, 32 deletions
diff --git a/lib/Reply/Plugin/Autocomplete/Methods.pm b/lib/Reply/Plugin/Autocomplete/Methods.pm
index 45a6507..f1fd8b0 100644
--- a/lib/Reply/Plugin/Autocomplete/Methods.pm
+++ b/lib/Reply/Plugin/Autocomplete/Methods.pm
@@ -1,9 +1,9 @@
-package Reply::Plugin::Autocomplete::Methods;
+package main;
use strict;
use warnings;
# ABSTRACT: tab completion for methods
-use base 'Reply::Plugin';
+use mop;
use Scalar::Util 'blessed';
@@ -22,37 +22,36 @@ code.
=cut
-sub tab_handler {
- my $self = shift;
- my ($line) = @_;
-
- my ($invocant, $method_prefix) = $line =~ /($fq_varname_rx|$fq_ident_rx)->($ident_rx)?$/;
- return unless $invocant;
- # XXX unicode
- return unless $invocant =~ /^[\$A-Z_a-z]/;
-
- $method_prefix = '' unless defined $method_prefix;
-
- my $class;
- if ($invocant =~ /^\$/) {
- # XXX should support globals here
- my $env = {
- map { %$_ } $self->publish('lexical_environment'),
- };
- my $var = $env->{$invocant};
- return unless $var && ref($var) eq 'REF' && blessed($$var);
- $class = blessed($$var);
+class Reply::Plugin::Autocomplete::Methods extends Reply::Plugin {
+ method tab_handler ($line) {
+ my ($invocant, $method_prefix) = $line =~ /($fq_varname_rx|$fq_ident_rx)->($ident_rx)?$/;
+ return unless $invocant;
+ # XXX unicode
+ return unless $invocant =~ /^[\$A-Z_a-z]/;
+
+ $method_prefix = '' unless defined $method_prefix;
+
+ my $class;
+ if ($invocant =~ /^\$/) {
+ # XXX should support globals here
+ my $env = {
+ map { %$_ } $self->publish('lexical_environment'),
+ };
+ my $var = $env->{$invocant};
+ return unless $var && ref($var) eq 'REF' && blessed($$var);
+ $class = blessed($$var);
+ }
+ else {
+ $class = $invocant;
+ }
+
+ my @results;
+ for my $method (methods($class)) {
+ push @results, $method if index($method, $method_prefix) == 0;
+ }
+
+ return sort @results;
}
- else {
- $class = $invocant;
- }
-
- my @results;
- for my $method (methods($class)) {
- push @results, $method if index($method, $method_prefix) == 0;
- }
-
- return sort @results;
}
1;