[Bast-commits] r4409 - trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver

Sartak at dev.catalyst.perl.org Sartak at dev.catalyst.perl.org
Mon May 26 04:19:18 BST 2008


Author: Sartak
Date: 2008-05-26 04:19:17 +0100 (Mon, 26 May 2008)
New Revision: 4409

Modified:
   trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Methods.pm
Log:
Have Methods completion driver use FindVariable to complete object methods


Modified: trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Methods.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Methods.pm	2008-05-26 03:13:54 UTC (rev 4408)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Methods.pm	2008-05-26 03:19:17 UTC (rev 4409)
@@ -2,6 +2,8 @@
 use Devel::REPL::Plugin;
 use namespace::clean -except => [ 'meta' ];
 
+with 'Devel::REPL::Plugin::FindVariable';
+
 around complete => sub {
   my $orig = shift;
   my ($self, $text, $document) = @_;
@@ -27,10 +29,21 @@
   # ..which is preceded by a word (class name)
   my $previous = $last->sprevious_sibling
     or return $orig->(@_);
-  $previous->isa('PPI::Token::Word')
+  $previous->isa('PPI::Token::Word') || $previous->isa('PPI::Token::Symbol')
     or return $orig->(@_);
-  my $class = $previous->content;
+  my $class;
 
+  # we have a variable, need to look up its class
+  if ($previous->isa('PPI::Token::Symbol')) {
+    my $object_ref = $self->find_variable($previous->content)
+      or return $orig->(@_);
+    $class = blessed($$object_ref)
+      or return $orig->(@_);
+  }
+  else  {
+    $class = $previous->content;
+  }
+
   # now we have $class->$incomplete
 
   my $metaclass = Class::MOP::Class->initialize($class);




More information about the Bast-commits mailing list