[Bast-commits] r4396 - in trunk/Devel-REPL/lib/Devel/REPL/Plugin: .
CompletionDriver
Sartak at dev.catalyst.perl.org
Sartak at dev.catalyst.perl.org
Sun May 25 17:50:10 BST 2008
Author: Sartak
Date: 2008-05-25 17:50:10 +0100 (Sun, 25 May 2008)
New Revision: 4396
Modified:
trunk/Devel-REPL/lib/Devel/REPL/Plugin/Completion.pm
trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm
trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/LexEnv.pm
Log:
Refactor the finding of the last element of the document into a method in Completion
Modified: trunk/Devel-REPL/lib/Devel/REPL/Plugin/Completion.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/Completion.pm 2008-05-24 01:18:27 UTC (rev 4395)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/Completion.pm 2008-05-25 16:50:10 UTC (rev 4396)
@@ -77,5 +77,16 @@
return ();
}
+# recursively find the last element
+sub last_ppi_element {
+ my ($self, $document, $type) = @_;
+ my $last = $document;
+ while ($last->can('last_element') && defined($last->last_element)) {
+ $last = $last->last_element;
+ return $last if $type && $last->isa($type);
+ }
+ return $last;
+}
+
1;
Modified: trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm 2008-05-24 01:18:27 UTC (rev 4395)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/Keywords.pm 2008-05-25 16:50:10 UTC (rev 4396)
@@ -7,11 +7,7 @@
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::Word');
Modified: trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/LexEnv.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/LexEnv.pm 2008-05-24 01:18:27 UTC (rev 4395)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/CompletionDriver/LexEnv.pm 2008-05-25 16:50:10 UTC (rev 4396)
@@ -14,11 +14,7 @@
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');
More information about the Bast-commits
mailing list