Have LexEnv wrap find_variable to first look at lexical variables. The around doesn...
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / PPI.pm
CommitLineData
c5bf3ed2 1#!/usr/bin/perl
2
3package Devel::REPL::Plugin::PPI;
4use Devel::REPL::Plugin;
5
6use PPI;
7use PPI::Dumper;
8
9use namespace::clean -except => [ 'meta' ];
10
11with qw(Devel::REPL::Plugin::Turtles);
12
13sub expr_command_ppi {
14 my ( $self, $eval, $code ) = @_;
15
16 my $document = PPI::Document->new(\$code);
17 my $dumper = PPI::Dumper->new($document);
18 return $dumper->string;
19}
20
21__PACKAGE__
22
23__END__
24
25=pod
26
27=head1 NAME
28
29Devel::REPL::Plugin::PPI - PPI dumping of Perl code
30
31=head1 SYNOPSIS
32
33 repl> #ppi Devel::REPL
34 PPI::Document
35 PPI::Statement
36 PPI::Token::Word 'Devel::REPL'
37
38 repl> #ppi {
39 > warn $];
40 > }
41 PPI::Document
42 PPI::Statement::Compound
43 PPI::Structure::Block { ... }
44 PPI::Token::Whitespace '\n'
45 PPI::Statement
46 PPI::Token::Word 'warn'
47 PPI::Token::Whitespace ' '
48 PPI::Token::Magic '$]'
49 PPI::Token::Structure ';'
50 PPI::Token::Whitespace '\n'
51
52=head1 DESCRIPTION
53
54This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump
55L<PPI>-parsed Perl documents.
56
57The code is not actually executed, which means that when used with
58L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
59
60=head1 AUTHOR
61
62Shawn M Moore E<lt>sartak@gmail.comE<gt>
63
64=cut
65
66