From c9f72cf51b809fe907db1faa4071f0baafeab20c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 27 Jun 2013 17:19:58 -0400 Subject: use the publisher for communicating the lexical environment --- lib/Reply/Plugin/Autocomplete/Lexicals.pm | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'lib/Reply/Plugin/Autocomplete/Lexicals.pm') diff --git a/lib/Reply/Plugin/Autocomplete/Lexicals.pm b/lib/Reply/Plugin/Autocomplete/Lexicals.pm index 47f9a95..e7c0c71 100644 --- a/lib/Reply/Plugin/Autocomplete/Lexicals.pm +++ b/lib/Reply/Plugin/Autocomplete/Lexicals.pm @@ -32,25 +32,11 @@ sub new { return $self; } -sub compile { +sub lexical_environment { my $self = shift; - my ($next, @args) = @_; - - my ($code) = $next->(@args); - - # XXX this is just copied from LexicalPersistence, which sucks first - # because of copying and pasting code, and second because it doesn't catch - # anything that wouldn't be caught by LexicalPersistence (setting lexicals - # via Devel::StackTrace::WithLexicals (Carp::Reply), setting extra lexicals - # (ResultCache)) - # we really need a way to broadcast various bits of information among - # plugins - $self->{env} = { - %{ $self->{env} }, - %{ peek_sub($code) }, - }; - - return $code; + my ($name, $env) = @_; + + $self->{env}{$name} = $env; } sub tab_handler { @@ -62,8 +48,11 @@ sub tab_handler { my ($sigil, $name_prefix) = $var =~ /(.)(.*)/; + my $env = { map { %$_ } values %{ $self->{env} } }; + my @env = keys %$env; + my @results; - for my $env_var (keys %{ $self->{env} }) { + for my $env_var (@env) { my ($env_sigil, $env_name) = $env_var =~ /(.)(.*)/; next unless index($env_name, $name_prefix) == 0; -- cgit v1.2.3-54-g00ecf