Refactor the finding of the last element of the document into a method in Completion
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / CompletionDriver / LexEnv.pm
index 2011896..f346bda 100644 (file)
@@ -14,11 +14,7 @@ around complete => sub {
   my $orig = shift;
   my ($self, $text, $document) = @_;
 
-  # recursively find the last element
-  my $last = $document;
-  while ($last->can('last_element') && defined($last->last_element)) {
-      $last = $last->last_element;
-  }
+  my $last = $self->last_ppi_element($document);
 
   return $orig->(@_)
     unless $last->isa('PPI::Token::Symbol');