From: Sartak Date: Tue, 27 May 2008 01:31:53 +0000 (+0000) Subject: r61086@onn: sartak | 2008-05-26 21:31:16 -0400 X-Git-Tag: v1.003015~96 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=commitdiff_plain;h=6d22063d380fc145987db58a1b6222a33a596c3e;hp=310ddf9f9d5d370f7b4aa89e7bbf4fd7f6a3814f r61086@onn: sartak | 2008-05-26 21:31:16 -0400 Hack to make LexEnv + FindVariable work (which makes lexical-object method name completion work) git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4415 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/FindVariable.pm b/lib/Devel/REPL/Plugin/FindVariable.pm index 2b35755..6dbf4ca 100644 --- a/lib/Devel/REPL/Plugin/FindVariable.pm +++ b/lib/Devel/REPL/Plugin/FindVariable.pm @@ -6,6 +6,12 @@ use namespace::clean -except => [ 'meta' ]; sub find_variable { my ($self, $name) = @_; + # XXX: this code needs to live in LexEnv + if ($self->can('lexical_environment')) { + return \( $self->lexical_environment->get_context('_')->{$name} ) + if exists $self->lexical_environment->get_context('_')->{$name}; + } + my $sigil = $name =~ s/^([\$\@\%\&\*])// ? $1 : ''; my $default_package = $self->can('current_package') diff --git a/lib/Devel/REPL/Plugin/LexEnv.pm b/lib/Devel/REPL/Plugin/LexEnv.pm index ea6d26b..4a272d1 100644 --- a/lib/Devel/REPL/Plugin/LexEnv.pm +++ b/lib/Devel/REPL/Plugin/LexEnv.pm @@ -44,14 +44,17 @@ around 'execute' => sub { return $self->$orig($wrapped, @rest); }; -around 'find_variable' => sub { - my $orig = shift; - my ($self, $name) = @_; - - return \( $self->lexical_environment->get_context('_')->{$name} ) - if exists $self->lexical_environment->get_context('_')->{$name}; - - return $orig->(@_); -}; +# this doesn't work! yarg. we now just check $self->can('lexical_environment') +# in FindVariable + +#around 'find_variable' => sub { +# my $orig = shift; +# my ($self, $name) = @_; +# +# return \( $self->lexical_environment->get_context('_')->{$name} ) +# if exists $self->lexical_environment->get_context('_')->{$name}; +# +# return $orig->(@_); +#}; 1;